All Questions
2,682 questions
0
votes
1
answer
85
views
Merge meta_value's into a single row and then loop
I have a query where I want to merge values from the wp_users and wp_meta tables, including the meta values of a given meta key. This key could have multiple entries.
SELECT
u.id,
(select ...
0
votes
0
answers
134
views
Is it possible to customize meta query in this way?
I have a custom post type called promotions.
In each promotions' post meta, I store two fields, promo_start_date and promo_end_date.
The idea is to only show promotions on the frontend, where the
...
-1
votes
3
answers
1k
views
Sort posts by post views and consider meta key
my code should show popular posts where the meta key "slider" isn't empty. Have anyone an idea why it doesn't work?
The problem is that this code only shows posts with a slider image. But it ignores ...
1
vote
0
answers
143
views
How to get meta box labels?
I know how to add a meta box, and I know how to retrieve meta box values. That's not what I need; I just want to clarify that first. What I need is to get meta box labels by id.
I am adding links to ...
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?
0
votes
1
answer
78
views
Shortcode attributes from meta query variables
In the following shortcode, I have two variable, $today and $tommorrow that are being called inside a custom meta query.
function display_prognostika_home_loop($atts, $content = null) {
// Get all ...
0
votes
0
answers
64
views
Meta box not displaying on the plugin page
I am working on a plugin and I am creating a meta box on my page using the below code but it's not displaying anything.
Any idea where is the issue with my code?
class bt_dashboard
{
function ...
-1
votes
1
answer
2k
views
WP User Query with meta queries
I'm having some problems when comparing integer values '>=' or '<=' with meta_queries with the WP_USER_QUERY.
Let say I've stored the following meta keys with the meta values below:
meta_key ...
-1
votes
1
answer
1k
views
Using get_posts, I need to use a combination of OR & AND relations
Using WordPress v4.6, I set up arguments for get_posts() based on price (2 conditions), sku, and categories like this:
[meta_query] => Array
(
[relation] => AND
[0] => ...
0
votes
1
answer
132
views
Meta query with string NOT ending like pattern
I need to find all posts that do NOT have in a specific meta key values ending with ".mp3". I know that I can use REGEXP for this, but I can't figure out how to do it. My code now returns ...
-1
votes
1
answer
1k
views
Adding Meta Box to Specific Submenu Page
I've created this page:
function wpdocs_register_my_setting() {
add_submenu_page(
'edit.php?post_type=task',
'View Tasks',
'View Tasks',
'manage_options',
'...
-1
votes
2
answers
794
views
Custom Metaboxes, multiple post selection
I have the following custom meta-box, which works to list a post type, I simply want to allow multiple values to be selected but cannot get it to work, it appears if I tell the select to store ...
10
votes
2
answers
9k
views
Reset positions of metaboxes in admin
I am writing a theme and in it I have a function which creates two metaboxes. The forth parameter of the "add_meta_box()" function I used can be set to ( high, core, default or low). I want the boxes ...
4
votes
3
answers
7k
views
Add custom option to Standard Page Attributes Meta Box
I'd like to add a simple checkbox option to the exsisting standard Page Attributes Meta Box.
Is there an obvious/intended way to do that using the WordPress API, rather than registering a new ...
1
vote
1
answer
300
views
get_post_meta bringing back results, but $wpdb->postmeta doesn't
I'm trying to discover if post exists, based on post_title & metadata post_language.
Until now, the best way I discovered, was using methods appearing in posts like this one, this one, or this one....
0
votes
1
answer
3k
views
Sort products by Sale price and stock status
I want to sort products by sale price and in stock and regular price at first but doesn't find solution anywhere. Here is what I have implemented and didn't get the solution:
add_filter( '...
-1
votes
1
answer
962
views
after checked the checkbox in backend, dont show social link on frontend
I want to do something like if I checked/unchecked a checkbox in admin then all social links in the page footer on fronted hide/show.
function add_custom_meta_box()
{add_meta_box("demo-meta-box", "...
-1
votes
1
answer
912
views
display all registered meta boxes
i want to display the list of all the meta boxes of each post. the global variable wp_meta_boxes would not print anything on the screen. how can i print the value of the array to get the list of all ...
2
votes
1
answer
1k
views
Best choice of options/settings framework for plugin/theme development
My question is what is the best options/settings framework out there now to safely build custom plugin/theme upon? I found the similar question here, but it was asked 7 years ago and definitely, ...
-1
votes
2
answers
799
views
wp_query sorting – one specific meta_key value at last and then sort by create date
I'm having a custom post type "products" of which I need to show a list. The products are sorted by meta value into different kinds of product type. I need to set one specific product type "tools" at ...
-1
votes
1
answer
818
views
Pagination not working on my archive page for a custom post type
First off I have a custom post type called events, and I wrote a custom query in in my archive-events.php file. Everything is working great except for the pagination.
To trouble shoot I stripped ...
0
votes
1
answer
139
views
Wp doesn't save meta box data
My WP doesn't save my meta box data. I see the metabox and the field, but the data doesn't saving. Somebody could help me? Thank you. This is the code:
// 1. Metabox létrehozása
function my_meta_box(){...
0
votes
1
answer
1k
views
Metabox value for post loop?
I created metabox.If the checkbox is checked if the posts are listed.
How do I browse the posts marked with checkbox ?
Metabox Code.
Metabox output:
-1
votes
3
answers
905
views
WP_Query returns empty if meta_query has more than 7 values
I have a custom loop to display a custom post type 'properties' . The idea is to search properties based on different search parameters selected by users. Now the weird problem I am facing is that if ...
-1
votes
1
answer
837
views
How to add a custom meta box below publish box in CPT that is like publish meta box and can contains html?
How can i add a custom meta box below publish box in CPT that will be like publish meta box and contain some html code? See the attached shot for more info.
0
votes
2
answers
762
views
meta_query compare not doing what I want it to do
I'm trying to run a query that only shows posts if it's meta value has a date string that is LESS than the current date's string. An example is below;
<?php
$current = date('Ymd'); // Eg: ...
0
votes
1
answer
156
views
WP_Query by meta key not returning any posts
I have set a custom meta key 'post_views' on a custom post type which I can see in my database has been added for 3 posts.
I now need to retrieve the ID's for these posts by searching for all posts ...
0
votes
1
answer
315
views
Custom Meta box change size
I a plugin that I have made (SNUP Widget) there is a strange error.
When I use widescreen monitor this custom meta box I made looks ok.
But with I open browser on my PC with split screen that is not ...
0
votes
0
answers
184
views
Wordpress Meta Query very slow with NOT EXISTS comparison
I need to get posts which do not have a certain meta key.
function handle_empty_date_paid($query, $query_vars)
{
if (!empty($query_vars['not_paid'])) {
$query['meta_query'][...
0
votes
0
answers
78
views
Hook to filter based on form value and insert term
I am working on a form where I am trying to insert a term to a taxonomy. So I have a drop down select with a list of my taxonomies and then the next field is a simple text field where the users will ...
1
vote
2
answers
11k
views
WP_Query with multiple meta fields filter?
I have the following query but it is still returning results which include posts which have a meta value of 'deal'.
Any Clues on what am i missing in this
$args = array(
'post_type' => ...
0
votes
1
answer
860
views
What is the meta_query key name for the woo product average rating? [closed]
I am asking about meta_query key name to query the woocommerce all product 5 star average rating in wp_query
I have tried to use these names but not working (_wc_average_rating , average_rating, ...
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 ...
0
votes
0
answers
45
views
How do I have multiple metaqueries inside one wordpress query
I have a parent->child relationship between artists and releases. There is another parent->child relationship between releases and versions aka albums, singles, videos, misc.
So artist is the ...
4
votes
5
answers
12k
views
Remove custom meta boxes from custom post type
Is there a way to create a custom post type in WordPress that will only include the default meta boxes and not any other meta box that was added by other plugins?
The idea is to use the custom post to ...
0
votes
0
answers
59
views
Function to Compare CPT Post Custom Value with Default Posts CF Value
I want to create function for compare custom field values of CPT Posts with default posts CF Value. As of now I implemented below code in template file which is working fine, but I want to create ...
0
votes
1
answer
768
views
Get_term with meta_query
I can figure out this query : my purpose is to have a list of taxonomys (category like) with the number posts related to AND from today, ignoring post with a taxonomy's date before today. Something ...
0
votes
0
answers
50
views
WP query with multiple custom meta not respecting orderby
I have created a wp query to pull a series of posts that have one of three categories (current, upcoming, or past) and I used the multiple custom meta array technique as I want the posts to display in ...
0
votes
0
answers
173
views
ACF meta_query field treated as "0" resulting in false negative search when testing ranges
I'm struggling a bit with building a correct meta_query search.
The query in question that fails:
if ($data['size']['size_from'] && $data['size']['size_to']) {
$args['...
6
votes
2
answers
25k
views
WP_Query() show posts that end later than today
I have a query as follows:
$wp_query = new WP_Query(
'meta_key' => 'end_date',
'meta_value' => 'today',
'meta_compare' => '>=',
'post_type' => 'vehicle'
);
I ...
0
votes
2
answers
53
views
Need to search a custom field (ingredients, one long string per post), but want it to allow phrases/non-exact matches
So I have a complex list of ACF repeaters for ingredients, but have a save hook to store them all as one comma delimited text string in a custom field to help. My current "advanced" search ...
1
vote
2
answers
2k
views
Set Default Option Value as Blank for Meta Box
My custom Meta Box has a drop down field, but how do I set the default Option Value to be blank? It is currently populating via the CPT's meta_value, but I'd like that to change.
Here's a screenshot ...
0
votes
3
answers
4k
views
Sanitizing text fields in array
I tried this code to create some meta boxes is all working fine, the problem I am facing is how to sanitize the text fields and update post meta
function Print_price_fileds($cnt, $p = null) {
...
0
votes
1
answer
346
views
meta_query where the meta value is not the post title
I have a meta_query where I am getting children of a page, I am trying to only get children where the meta key is not the same as the posts title
$args = array(
'posts_per_page' => -1,
'parent' ...
2
votes
1
answer
266
views
get_terms_args ordering by meta key not working
I have a custom taxonomy called "edition". Each edition has a meta key "_edition" that stores an incremental number from 1 to N. So, if I have an edition called "Edition 13&...
0
votes
1
answer
502
views
Display posts with specific value first in query
I would like to display posts that have a certain value in a meta field first. I would like to display posts that have a certain value in a meta field first. I have tried it with meta_query and ...
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 ...
0
votes
1
answer
530
views
Filter posts by meta key
I would like to implement a search function where a user can enter an amount($amount) and based on that argument the search result needs to show all posts where $amount >= loan_min (meta key) AND $...
6
votes
4
answers
15k
views
SELECT max(meta_value) FROM wp_postmeta WHERE meta_key='price'... stops working when value is over 999
Overview: I am not trying to return a post. I simply want the single highest value for a particular meta_value across all posts... just the value itself.
Details: I have added a custom meta_key "...
0
votes
0
answers
24
views
meta_query weird behaviour, static int will work, but not user data
I am currently trying to build a Ajax filter for a CPT, all the products have a min and max value of a specific range in which the products works best. Therefore i created ACF groups with a min and ...