Skip to main content

All Questions

Tagged with or
Filter by
Sorted by
Tagged with
1 vote
1 answer
4k views

How to add a select menu to this metabox code?

I'm using a metabox script that works great for having absolute control over the design and placement of the metabox fields. There is one problem: I can't remember where I found the script and need to ...
MTT's user avatar
  • 3,576
1 vote
0 answers
76 views

How can I create a WP_Query that returns posts where one meta_value <= another meta_value

I have a working, pretty complex SQL query hand-written in a function. For the sake of leveraging WP_Query optimizations, and simplifying my code for maintainability, I'd like to convert it all to ...
pjv's user avatar
  • 131
1 vote
1 answer
241 views

$post->ID incorrect within meta box

I have a meta box and I am trying to get the current post id however I am getting the ID of a different post. Is there another way to get the ID? function global_notice_meta_box() { $screens = ...
Ben H's user avatar
  • 403
1 vote
2 answers
1k views

What's wrong with this meta query? (order by meta key, then title, doesn't work)

Here's my meta query: $taxonomy_term = 1494; $args['meta_query'] = array( 'relation' => 'OR', 'mp_exists' => array( 'key' => 'tdlrm_mp_'.$taxonomy_term, ...
Artem's user avatar
  • 315
1 vote
1 answer
339 views

Save / Show multi line text in metabox

In a plugin I have made (Snup Widget) I have made a metabox. In the sample here I have made two line with text. When I want to show the text in output in the widget it shows in one line, without break....
bjovaar's user avatar
  • 21
1 vote
2 answers
3k views

pre_get_posts filter using numeric meta_query comparison (from dates)

I have an expiry date ACF field 'post_end_date' which has been applied to multiple post types, including 'post'. I'm trying to filter out any posts, across the entire site, where today's date is ...
Rhecil Codes's user avatar
1 vote
2 answers
2k views

How to query 'posts_per_page' to display a different blog posts index template?

Trying to create a 'switching' blog template using home.php, controlled by 'Blog posts per page' setting in the admin area. If set to '1', it will show the single post template. Anything higher and it ...
user avatar
1 vote
1 answer
1k views

get_post_meta causes database queries

I want to know why my site's search results are slow. I've used the excellent Debug Bar plugin, and found out that each search result causes 5 DB queries, of which 3 are SELECT meta_key (see below for ...
Jonathan's user avatar
  • 125
1 vote
1 answer
147 views

update custom post type meta from a shortcode

I have the following scenario: I have a custom post type called "tablepress_tables" that is create by the plugin "Wordpress", Tablepress has a shortcode to display the number of rows which is [table-...
Ibrahim Hassan's user avatar
1 vote
1 answer
534 views

meta_query problem

I have a meta_query that works when its like this: $args = array( 'number' => $users_per_page, 'offset' => $offset , 'orderby' => 'registered', 'order' => 'DESC', ...
Nelson101's user avatar
1 vote
1 answer
762 views

update a post meta from a single table cell TablePress

I have the following scenario I have a lot of tables created by TablePress. one column in them is called Size which displays the size of some files in bytes. tablepress have a summing function called "...
Ibrahim Hassan's user avatar
1 vote
1 answer
3k views

WooCommerce: filter by parent product's taxonomy and product variation's meta data

In WooCommerce, I would like to filter my products page based on product variation's meta and related variable products's taxonomy. Note: All products have variations, there's no product without ...
Gia Bao Nguyen's user avatar
1 vote
2 answers
4k views

Using Query Posts With Multiple Post Types And A Taxonomy

I am developing a site that has two different custom post types; one of them is called Articles and one is called Sketchpad. Sketchpad is user submitted content that is assigned a custom taxonomy term ...
Dwayne Charrington's user avatar
1 vote
5 answers
790 views

meta content on required pages

I need to post extra information on programs pages, so i have decided to use wordpress metabox but its showing on all pages. So is there any condition check so it could put meta box on those sub pages ...
seoppc's user avatar
  • 165
1 vote
1 answer
964 views

How to List all Sidebars in a Metabox

I'm trying to add a metabox to every page that is a drop down list of all registered sidebars that is then saved in a custom field. I'm using this metabox class I've gotten as far as this: // get ...
fshequin's user avatar
1 vote
1 answer
9k views

PHP Warning: call_user_func() expects parameter 1 to be a valid callback

Confused. Writing a plugin with which I have other callbacks working similarly fine. But when adding a meta box its failing on the callback with error: PHP Warning: call_user_func() expects ...
Jimbo's user avatar
  • 151
1 vote
1 answer
1k views

How to stop wordpress from mangling HTML in a metabox textarea

Can anyone lend a hand and suggest the best way to get a textarea in a meta box to stop mangling HTML? I've been digging around here online... and here...and also here...looking for answers, but I ...
Nadine's user avatar
  • 377
1 vote
1 answer
825 views

Remove border on custom meta box

How can i remove the border/box on a custom meta box? I need to remove the class "postbox" from a custom meta box, so that it looks just plain. How can i do that?
Kevin Simper's user avatar
1 vote
2 answers
5k views

Creating Custom Meta Boxes on Plugin Option Page

Right in my main plugin file, wp-email-capture.php I am calling this:- add_action( 'admin_init', 'wp_email_capture_add_custom_boxes'); This calls this function:- function ...
Rhys Wynne's user avatar
1 vote
1 answer
286 views

Embed 'New Post' Form Inside 'New Post' Form

Is it possible to embed a 'New Post' form for one Custom Post Type inside of a 'New Post' form for another Custom Post Type? When a user adds a new post for the custom type 'Event', they should also ...
cantera25's user avatar
  • 145
1 vote
1 answer
311 views

Create custom field key upon theme activation

Upon theme activation I want to create an 'URL' key for the custom fields. Like in . I know who to run functions when a theme is activated, I don't know how to create this custom field key though. ...
ditto's user avatar
  • 117
1 vote
1 answer
573 views

Choosing a default page tempate (Classic => Gutenberg)

This code was working in the "Classic" era to set a default page template: /* Blank Page by default */ add_action('add_meta_boxes', 'blank_default_page_template', 1); function ...
user avatar
1 vote
1 answer
683 views

Use Custom Post Type as Custom Field

I want to create a custom post type for store that having all store names and it is working. Now I want to fetch the all stores in a select box in every new post of WordPress, then selected store name ...
Sachin's user avatar
  • 13
1 vote
1 answer
892 views

TinyMCE in Custom Metabox not loaded after upgrading from WP 3.1.4 to WP 3.2

I want something very simple: a custom metabox with a TinyMCE editor in it. The following code help me achieve that easily in 3.1.4: add_action( 'add_meta_boxes', 'add_metaname_box'); function ...
Eugene's user avatar
  • 45
1 vote
1 answer
4k views

get_post_meta doesn't work

I created a custom meta box inside a page but I can't display the content! I'm inside the loop and here there is the code of my functions.php: $meta_box['portfolio'] = array( 'id' => '...
dborghez's user avatar
  • 129
1 vote
3 answers
9k views

Get the term id belonging to custom taxonomy on a custom single-post-type.php template page

I have custom post-type 'sermon' with custom taxonomy 'speaker' attached to it. I wanted to assign custom meta values to the speaker taxonomy, so I am using the taxonomy meta class from Rilwis: http:/...
shawn's user avatar
  • 742
1 vote
1 answer
6k views

How to order a post type with meta_value_num and if meta_value_num does not exist then order by date

I want to order a list of post on basis of ratings. I have used meta key "wp_ratings" for storing the rating value in wp_postmeta table. Now I want to sort all posts . If a post does not contains the ...
Aftab's user avatar
  • 1,391
1 vote
3 answers
5k views

Conflicting save_post functions when passing the post id and saving custom meta boxes for different post types

Post save functions are conflicting with each other when adding them to the save_post action hook. 2 different custom post types with 2 different (one for each post type) custom meta boxes. I'm ...
Chris_O's user avatar
  • 20.6k
1 vote
1 answer
2k views

WP_User_Query with meta_query array relation 'OR'

I just updated to WP 4.1 and a User_Query I was using is now returning 0 instead of the expected results. $pm = array( //'role' => 'program_manager', 'orderby' => 'display_name', '...
Sean's user avatar
  • 13
1 vote
1 answer
2k views

Possible to create a permalink to sort with meta_key?

I feel like I've been all around the web and back again looking for an answer to this and it's really starting to grind my gears. Not sure if this is the correct way to do it, but I want to add a ...
andy's user avatar
  • 2,359
1 vote
2 answers
952 views

Unbind postbox click handler

I'm trying to unbind the click handler on post metaboxes so they no longer hide when the handle is clicked. I need to do this because I use the handle to contain <select> elements & when ...
studioromeo's user avatar
1 vote
1 answer
943 views

Save or update data when custom post published

I have metabox on my custom post screen. How to save them when any of them are checked and then use or echo those checked offers to display on single.php? my code for metabox is function ...
Nimesh's user avatar
  • 441
1 vote
2 answers
1k views

Save checkboxes of a metabox with a foreach loop (invalid argument)

I'm new to Wordpress plugin development and I'm trying to create a list of checkboxes (from a WP Query) to associate as custom fields for a specific post type. Nothing wrong with the display function, ...
Alessio's user avatar
  • 13
0 votes
1 answer
4k views

How to get all post_id and meta_value using meta_key in wp_postmeta table

The wp_postmeta table has the following columns: meta_id, post_id, meta_key, meta_value I insert post id, meta key and meta_value like: $arrg = array( 'require_login' => 'Yes', 'restrict_by'...
Md. Mehedi Hassan's user avatar
0 votes
0 answers
3k views

Combine tax_query and meta_query in WP_Query

I'm building a search in WordPress. I look for a custom_post_type in combination with several custom taxonomys and metadatas. custom_post_type: vehicle taxonomys: brand, fueltype, ... metadata: ...
wellseo's user avatar
  • 71
0 votes
1 answer
25 views

Problem with adding exta field in metabox in custom post type

I am trying to add a new field in the metabox there is demo url field which is working fine i have created new field that is not storing or saving any datas which inserted into the field. Here is my ...
James Paul's user avatar
0 votes
1 answer
299 views

custom meta box data not saved

After two day of reasearch and questions without answer, today someone has suggested me a way to add a custom metabox field to the wordpress images. My scope is to add an url when the image are ...
sialfa's user avatar
  • 329
0 votes
1 answer
705 views

Calculate Repeater Meta Box Input Field Values and Display Total

I have a repeater custom meta box for my custom post type. I am new to Javascript and can not figure out how to calculate the value for each repeated input field and display the total combined. I have ...
Kevin W.'s user avatar
0 votes
1 answer
876 views

How to display liked posts of current user in wordpress?

Im using an ajax like dislike post system on my wordpress theme. When the user likes the post there are some post metas to update or to add like the following: if( $post_like == "like" ){ ...
Gazi's user avatar
  • 101
0 votes
1 answer
197 views

Ordering posts by anniversary using only day and month

I defined a custom field named crimedate using standard date format Y-m-d. I defined the filters to make ordering by this date work in the post list of the backend, which works fine. Now I need the ...
geraldo's user avatar
  • 145
0 votes
1 answer
59 views

Display two post types ordered by two custom fields

I have two custom post types, created by two third party plugins, that I want to display by the main query in a common ordered list. They must be ordered by two distinct custom fields, but with the ...
Yuri's user avatar
  • 1,131
0 votes
1 answer
215 views

How to set up hierarchical relationships without using plugins / meta query

I'm running a large database of musical artists and their releases. I inherited the site after it running for a long time. There are currently several different custom post types, created with a ...
DJZEEGLER's user avatar
  • 119
0 votes
0 answers
446 views

WordPress creating excessive joins on meta_query with search

I've a pre_get_posts filter with a check for main query and search, in this check I add a meta query: $meta_query = array( 'relation' => 'OR', array( 'key' => 'exclude', 'value' =&...
Aravona's user avatar
  • 585
0 votes
1 answer
1k views

Slow meta query with multi meta keys

I have problem with filtering posts by custom fields. On my page I have form with 15 conditions (radiobutons and inputs) and i'd like to filter with them my custom post type PROJEKT. My problem is ...
user3689240's user avatar
0 votes
2 answers
3k views

Comparing timestamps in meta query doesn't work

I want to compare two timestamps in a meta_query instead of comparing two dates in the "Y-m-d" format, each of them stored separately in custom fields, but no success. The first timestamp is an event ...
Yuri's user avatar
  • 1,131
0 votes
1 answer
153 views

Custom Meta Boxes - Nonce Issue - Move to trash issue

Recently after updating Wordpress from 4.9.2 to 5.2, I have had to change a good bit of code to get my custom post type listings(or posts) to function and save data correctly. Specifically, with the ...
Preston's user avatar
  • 11
0 votes
1 answer
70 views

How to save the checked boxes?

What i am trying to achieve is this I have created a custom post(offer), i have another custom post created (listing). I want to add a metabox in listing, which will recieve check list of all offers ...
Nimesh's user avatar
  • 441
0 votes
2 answers
564 views

wp_editor in add_meta_boxes does not show gallery

I have added a meta box in the page edit section: add_meta_box('custom_section_box', 'Sections', array($this, 'section_box'), 'page','normal','high'); Within the box, there is a wp_editor call: $...
sariDon's user avatar
  • 265
0 votes
1 answer
3k views

Displaying Saved Meta Box Data in Drop Down with selected()

I have a custom meta-box for certain custom post types, and one of those fields in the meta-box is a drop down. I am providing the field correctly, saving the information, and even calling it ...
RCNeil's user avatar
  • 548
0 votes
2 answers
7k views

How To Create a Metabox of HTML Content with Instructions For Editors When Editing a Post or Page?

I would like to add a custom Metabox with HTML content in the screens New and Edit Posts/Pages ( /wp-admin/post.php?post=POST_ID&action=edit), so that I could display a list of editorial ...
Bakaburg's user avatar
  • 473