Used for questions about Wordpress ( from https://codex.wordpress.org/ : WordPress Codex, the online manual for WordPress and a living repository for WordPress information and documentation)
Questions tagged [codex]
80 questions
11
votes
4 answers
Adding custom post type / post to Woocommerce
I have a personal theme "A" and I want that it can also work without Woocommerce.
When Woocommerce "WC" plugin is added I would integrate A products with WC. I have a custom post type called "objects", how can I make "object" buyable throught…

Delayer
- 409
- 1
- 5
- 17
10
votes
5 answers
insert post ID with wp_insert_post
how can I choose post ID, when inserting new post, ex:
$post = array(
'ID' => 3333,
'comment_status' => 'open',
'post_content' => 'hi world!',
'post_name' => 'title_1',
'post_status' => …

mwafi
- 3,946
- 8
- 56
- 83
9
votes
3 answers
How can I have default values for options for a WordPress Plugin?
Or how can I populate wordpress database with default plugin values, add option doesnt works for me, like http://codex.wordpress.org/Function_Reference/add_option
I am sure my syntax is correct, what I want is, when the user goes to the settings…

WebDDelhi
- 93
- 1
- 3
5
votes
1 answer
How to invoke Github Copilot programmatically?
I am currently exploring GitHub Copilot, and I am interested in using it programmatically, i.e., invoking it from code. As I understand, GitHub Copilot is an IDE plugin, which makes me wonder how it can be automated or controlled programmatically.…

Exploring
- 2,493
- 11
- 56
- 97
5
votes
4 answers
File path without domain name from wp_get_attachment_url()
wp_get_attachment_url() process full file path like
http://example.com/wp-content/uploads/2014/12/aura.mp3
I want the url without http://example.com/
So, I want above example as wp-content/uploads/2014/12/aura.mp3 instead of…

Sahriar Saikat
- 613
- 2
- 7
- 17
4
votes
2 answers
get_template_directory_uri() in Jquery and CSS
I am trying to use get_template_directory_uri() to load images to a jquery.backstretch.js file and to my styles.css as well. So far, I added my images directly in the theme folder in a folder named "img" and I have used this for my HTML:

LOTUSMS
- 10,317
- 15
- 71
- 140
4
votes
1 answer
How do I get activated plugin list in wordpress plugin development?
Is there any way to get all activated plugin list in wordpress codex .
i used this
get_option('active_plugins');
this return the plugin file path. I want the name. Because sometimes file name is different with the actual plugin name.

Sarwar Hasan
- 1,561
- 2
- 17
- 25
3
votes
1 answer
Prevent wordpress from compromising image quality before uploading
Wordpress keeps applying some kind of compression during uploads to my images thereby compromising with the quality. Where do i deactivate this functionality. I have already tried ..
function add_image_size( $name, $width = 0, $height = 0, $crop =…

john zuh
- 59
- 1
- 11
3
votes
1 answer
Default featured image for 'POST' type only (exclude 'page')
Hello I am trying to have a default featured image set for post_type = 'post' only excluding post_type = 'page'.
I wrote the following code in the functions file of the child theme but i keep getting this error:
Notice: Trying to get property of…

vanegeek
- 713
- 2
- 10
- 22
2
votes
0 answers
Bulk Update Wordpress user roles by ID
I'm trying to figure out how to loop through an array of user id's and call the wp_update_user function to update roles in wordpress.
The problem is that is stops looping after 10 changes even though there are 85 items in the array.
I thought maybe…

Laurie Williams
- 69
- 3
2
votes
0 answers
wp_pagenavi doesn't work with WP_Query from page2
wp_pagenavi doesn't work from page 2.
[OK] url/wordpress/2013/06/
[NG. 404 error occured] url/wordpress/2013/06/page/2/
I tried some plugins, but nothing changed.
This is my code.
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$args…

Jagie
- 83
- 1
- 10
1
vote
2 answers
meta_query search names when they have middle initials - PHP, WordPress
I have to build a search form where I search members of the company by their Full Name (First Name + Middle Initial + Last Name). All the names are in this form: John B. Doe.
The below code is working on these cases: John, John B., Doe, B., John B.…

ah92
- 307
- 5
- 20
1
vote
1 answer
how to limit the number posts per page
In creating my theme, I want to show one sticky post in a loop but unfortunately, all sticky posts (there are 5) are displaying. I just want to show 1 or two but I am unable to do so through my coding.
I don't know what I am missing or what I am…

Jeeshan
- 65
- 6
1
vote
1 answer
What is expected DATETIME format for Wordpress Codex WP Meta Query parameter?
This docs:
https://codex.wordpress.org/Class_Reference/WP_Meta_Query
Tells you can compare DATETIME values.
What is expected format of DATETIME for WP_Meta_Query?

Tom Smykowski
- 25,487
- 54
- 159
- 236
1
vote
1 answer
wp_link_pages and the_posts_pagination → whats the difference
REQUIRED: The theme doesn't have post pagination code in it. Use
posts_nav_link() or paginate_links() or the_posts_pagination() or
the_posts_navigation() or next_posts_link() and
previous_posts_link() to add post pagination.
REQUIRED: Could not…

WordCent
- 725
- 3
- 18