All Questions
301 questions
49
votes
2
answers
25k
views
Create more Meta Boxes as needed
I'd like users to be able to create and remove additional meta box fields as needed.
For example, say a music podcast with a variable amount of songs played per episode.
The user should be able to ...
51
votes
14
answers
81k
views
meta_query with meta values as serialize arrays
I'm working on a project in which I'm creating a custom post type and custom data entered via meta boxes associated with my custom post type. For whatever reason I decided to code the meta boxes in ...
27
votes
4
answers
37k
views
How to set default screen options?
I'd love to be able to hide meta boxes using screen options, instead of removing them or restricting them to user roles, the goal is to just "uncheck" the meta box for the user.
I see how this would ...
21
votes
2
answers
63k
views
Add "upload media" button in meta box field
I have a custom post which has a meta tag that needs to be using a file upload (for video files). I am wondering, what is the correct way of adding an "Upload" button that points to the WordPress ...
23
votes
1
answer
43k
views
Order by multiple meta key and meta value [closed]
How can I set multiple meta keys order by meta value, can any one give me some example?
12
votes
6
answers
10k
views
Removing panels (meta boxes) in the Block Editor
When the Block Editor was added to WordPress, custom and core meta boxes became legacy, meaning, using the remove_meta_box() function won't work when removing meta boxes/panels displayed on the post ...
10
votes
1
answer
2k
views
What is the index [0] for on post meta fields?
Trying to improve my PHP knowledge through test and try! I am confused on [0] arguments at following WordPress PHP code
global $post;
$custom = get_post_custom($post->ID);
$price = $custom['price']...
36
votes
5
answers
38k
views
How can I put a custom meta box above the editor but below the title section on the edit post page?
I have a custom meta box for a custom post type that my client wants placed between the title/permalink section and the post editor in the admin panel. Is this possible and if so is there a hook/...
31
votes
5
answers
85k
views
How can I create a meta_query with an array as meta_field?
Here are the args for my query :
$args = array(
'post_type' => 'news',
'meta_query' => array(
array(
'key' => 'topics',
'value' => 'sports',
...
18
votes
5
answers
9k
views
Can I add a Category Metabox to attachment?
I am using register_taxonomy_for_object_type() to add the Category taxonomy field to Media uploads (attachments). I'm using this code to do so:
add_action('init', 'reg_tax');
function reg_tax() {
...
12
votes
3
answers
22k
views
WP Query Args - Title or Meta Value
How do I query by meta_value or title?
If I set meta_values,
$args['meta_query'] = array(
'relation' => 'OR',
array(
'key' => 'model_name',
'value' => $thesearch,
...
4
votes
2
answers
2k
views
How to add or remove metabox each page separately?
How to add a meta box for a particular page, say: for only About Us page.
How shall i do?
The current code adds the metaboxes for all pages:
function myplugin_add_custom_box() {
add_meta_box(
...
63
votes
2
answers
181k
views
Meta_query compare operator explanation
I noticed that there are bunch of operator can be use for compare in meta_query.
However, I am not quite sure what operator I should use, it is somehow confusing like = and LIKE operator.
I would ...
23
votes
2
answers
18k
views
How to show a custom meta box on the "Quick Edit" screen?
I've used add_meta_box() to add a custom meta box to the WordPress edit window on both pages and posts.
How can I make this meta box also show on the "Quick Edit" screen?
Ideally, I'd like it to ...
22
votes
4
answers
14k
views
Passing error/warning messages from a meta box to "admin_notices"
I have a simple meta box that updates the post custom fields (using update_post_meta()).
How can I send a error or warning message to the next page after the user publishes/updates the post and doesn'...
18
votes
5
answers
16k
views
Filtering multiple custom fields with WP REST API 2
I want to filter posts based on multiple acf custom fields with AND relation. Something like this:
$args = array(
'post_type' => 'product',
'meta_query' => array(
'...
9
votes
2
answers
9k
views
Get List of Registered Meta Boxes and Removing Them
Is there a function for getting a list of registered Meta Boxes and removing them? I see there is a method for adding, and removing.
http://codex.wordpress.org/Function_Reference/remove_meta_box
...
2
votes
2
answers
1k
views
Modifying the main editor priority
I want the main WordPress post editor to appear below some of my meta boxes (generated by Advanced Custom Fields).
I know there are the add_meta_box() and remove_meta_box() functions, however it'd be ...
1
vote
1
answer
7k
views
Custom meta box shown when template is chosen [duplicate]
Possible Duplicate:
Toggle admin metabox based upon chosen page template
Is this possible to change editor screen immediately after someone picks some template from the drop down?
I need a ...
40
votes
14
answers
105k
views
Using meta query ('meta_query') with a search query ('s')
Trying to build a search that not only searches the defaults (title, content etc) but also a specific custom field.
My current query:
$args = array(
'post_type' => 'post',
's' => $query,
...
20
votes
8
answers
13k
views
Disable dragging of meta boxes?
Anyone know how to disable this functionality so the meta boxes can't be repositioned?
16
votes
2
answers
5k
views
Help Creating a Slideshow Custom Post Type with Custom Meta Boxes?
I need to create a custom post meta box(es) for my custom post type "Slideshow" (this post type is already created). Each metabox will hold the content in each slide slide and save it to ...
11
votes
2
answers
12k
views
How to HIDE everything in PUBLISH metabox except Move to Trash & PUBLISH button
I have a custom post type (called contacts).
Since this post type is not working like a post, I don't want to show SAVE DRAFT, PREVIEW, Status, Visibility or Publish Date.
The only options I want to ...
9
votes
1
answer
6k
views
How do I position meta_box on post edit screen after the title?
I am displaying a div in the Edit Post screen using add_meta_box(). This function provides very limited positioning options via "priority" and "context" params and these are not sufficient for my ...
7
votes
3
answers
2k
views
How to Add Reminders/Notes to New Post Meta Boxes
I have a multi-author website and I use the WyPiekacz plugin to require that authors add 1-5 tags, select only a single category, and include a featured image (and require minimum dimensions for the ...
3
votes
2
answers
8k
views
filter search result with custom post type meta key
The default search returns all post types, which is what I want. But for one specific custom post type I want to limit the result to a specific meta key value (a custom date that must be greater than ...
1
vote
1
answer
4k
views
Dynamic page.php template for custom post types
I have a couple of custom post types registered. I would like to display all "posts" from each custom post type on its own page, and these pages must be visible in the nav menu.
It would be great to ...
31
votes
3
answers
21k
views
Set Default Admin Screen options & Metabox Order
I am desperately looking for some way (any way) to set default "screen options" and metabox order through the functions.php file. does anyone have any help they can provide here?
17
votes
3
answers
35k
views
How to do a meta query using REST-API in WordPress 4.7+?
I am trying to filter by a meta query but no matter what I try I can not make it work.
Basically I want this query in through the rest API:
wp-json/wp/v2/books?meta_query[relation]=OR&meta_query[...
16
votes
6
answers
15k
views
Trigger Javascript on Gutenberg (Block Editor) Save
So I have a metabox which I want to trigger some Javascript when a post is saved (to refresh the page in this use case.)
In Classic Editor, this can be done via a simple redirect hooked to save_post ...
11
votes
1
answer
16k
views
Meta query with string starting like pattern
I have a custom WP_Query with the following meta_query:
$meta_query = array();
$meta_query['relation'] = 'AND';
if(!empty($postcode)) {
$meta_query[] = array(
'key' => 'postcode',
...
11
votes
2
answers
11k
views
Custom field/meta populated by dropdown of existing posts?
(My first WP question ever asked! Be gentle!)
I'm building a site that is mostly pages (i.e., static), using WP as CMS. At the bottom of several of the pages, there will appear 1, 2, or 3 "promo ...
10
votes
6
answers
16k
views
Change The Title Of a Meta Box
I'm trying to create a function that would allow me to change the title of an established meta box (i.e, change Meta Box title 'Authors' to 'Team', etc.)
I didn't want to use JS or have to unset the ...
10
votes
5
answers
14k
views
WordPress SEO by Yoast: Hide Meta Boxes in Posts for Non-admins
I have multi-author website and I am not very comfortable for allowing all members to enter SEO details in the posts they are publishing. I would like this would be visible only to Administrator of ...
10
votes
2
answers
9k
views
Query WP REST API v2 by multiple meta keys
Using v2 of the REST API, I'm wanting to query some posts by multiple meta keys. With v1 I was able to format the url like &filter[meta_value][month]=12&[meta_value][year]=2015 and it worked (...
8
votes
3
answers
11k
views
How to query posts based on lat-lng coordinate as post meta?
I'm planning a custom WordPress theme where the Custom Post Type (CPT) will have latitude and longitude coordinate as it's meta value. The latitude and longitude will be displayed as a Marker in a ...
8
votes
2
answers
26k
views
Post custom metabox textarea using wp_editor
I'm a novice and looking to add the wp_editor to a custom metabox textarea field. I've looked seemingly everywhere for an complete example for writing a metabox with a textarea that uses the wp_editor....
4
votes
1
answer
2k
views
How do you remove a Category-style (hierarchical) taxonomy metabox?
I was wondering if someone can help me with this. I'm currently following Shibashake's tutorial about creating custom meta-boxes that include taxonomy selection here: http://shibashake.com/wordpress-...
4
votes
1
answer
3k
views
Metabox repeating fields - radio buttons not saving correctly
I have multiple radio buttons set up inside of a metabox in a custom post type. I have created the metabox like so:
add_action('admin_init', 'add_meta_boxes', 1);
function add_meta_boxes() {
...
3
votes
3
answers
7k
views
Adding submit or update button to custom metabox?
I have alot of custom meta boxes, and the user has to scroll to the top everytime he wants to save the meta info.
Is there a way to put submit buttons at every meta box that does that same as the ...
3
votes
1
answer
56k
views
Add special meta box to custom post type
I have managed to add a meta box to my custom post type (see code below)
Now I need to add another meta box. With this box I want to display / edit a value from another table called ...
2
votes
3
answers
7k
views
How to make a meta box field a requirement
I'm building a plugin that has a meta box. Some of the fields in the meta box are required. Is using jQuery the only method for achieving this? Can I require that a field is filled in using PHP?
2
votes
2
answers
899
views
How to activate "Description" metabox for menu item programmatically?
I'm creating custom wordpress theme. How can I enable "Description" metabox for menu items (on nav-menu page) by default programmatically?
2
votes
1
answer
4k
views
How to sort CPT by custom meta value (date), and return posts month by month
For future reference:
I am using the great Meta Box Plugin to help expedite meta box creation for my custom post types.
My goal:
To build a highly customizable events section closely resembling a ...
32
votes
3
answers
92k
views
Nested meta_query with multiple relation keys
I am curious whether Wordpress is able to run nested meta_query, with each having different relation keys? As of Wordpress 3.0, tax_query is able to perform this function; I'm wondering whether this ...
21
votes
3
answers
22k
views
How to change default position of WP meta boxes?
Im wondering if there is a way to change the default position of Wordpresses meta boxes such as "featured image" for custom post types without having to drag them manually?
Example:
18
votes
6
answers
24k
views
Add a Meta Box for uploading a SECOND Featured Image?
I'd like to add a meta box to my posts and page editor that will allow me to upload an image and use it as sort of a SECOND featured image. The idea is that my client will be able to upload an image ...
15
votes
3
answers
35k
views
Custom Taxonomy as checkbox or dropdown
I have registered a custom tax to my CPT. On the edit screen the tax meta box appears with an autocomplete field.
Is it possible to display it as checkboxes or dropdown instead?
8
votes
2
answers
9k
views
Sorting: custom query with orderby meta_value_num THEN by title
i try to run a custom post type query to match following criteria:
sort movies first by year in descending order,
after that ("inside" the year order) by title alphabetically.
desired output:
...
8
votes
2
answers
13k
views
Remove the Yoast SEO Post Metabox [closed]
Yoasts SEO plugin adds a metabox to the post edit screen. I'm trying to remove this for users who aren't editors or above.
I've tried putting a remove_meta_box call in on admin_init, trying to remove ...