New answers tagged

-1

In your case you don't need any of these functions on $x, because its values are created by for loop and are safe.


2

Based on WordPress documentation for esc_attr function, it is returning a string value. So, If you need to have the integer value, you need using intval function. But, when you want to display that value or put it as part of markup, it doesn't make sense. Escape functions are useful for outputting and printing values. If you want to save a value in the ...


0

With this code you can search in post list in WordPress Admin Panel with custom post meta values along with title and other default fields. Please, add below code in functions.php file: if (!function_exists('extend_admin_search')) { add_action('admin_init', 'extend_admin_search'); /** * hook the posts search if we're on the admin page for our ...


0

I think the problem might be that the spread operator is missing in a couple of places. This line: return { meta: { currentMeta, editedMeta }, }; in withSelect should be: return { meta: { ...currentMeta, ...editedMeta }, }; This makes the meta object be a copy of currentMeta (have all the same properties and values), but overwrites them with ...


1

Option 1: force featured image on all posts Use the save_post hook, which runs twice per "save" action if you have revisions enabled. You can verify it's the final run by checking that there is $_POST data (it's empty the first time around). add_action('save_post', 'wpse_force_featured_image', 20, 2); function wpse_force_featured_image($post_id, $post) { ...


0

Resolved! Had to disable the Open Graph option on the Theme control panel!


0

I would probably take an alternative route and let the serialization happen at the end after the data was already merged like in the example below. So first query meta data for both old keys. Then merge the old data into an array (regular or associative) with post ID as key. Then use the resulting array in a loop which uses update_post_meta to let it ...


1

I think the issue is that it's being interpreted as a STRING type and being ordered character by character. Maybe try turning this into a meta query and forcing the DATETIME type like the example shown below: 'meta_query' => array( 'starttime' => array( 'key' => 'start_time', 'type' => 'DATETIME', ) ), 'orderby' => ...


0

Try: $all_pms = new WP_Query( [ 'post_type' => 'pms-subscription', 'post_status'=>'active', 'meta_query'=>[ 'meta_key'=>'pms_subscription_plan_price', 'meta_value'=> '126', // string 'meta_compare' => '=', // or > or < or != ] ] ); https://developer.wordpress.org/reference/classes/wp_query/#custom-...


0

In the WP Docs you can find the answer. I have not tested this snippet, but it should become something like this: $args = array( 'post_type' => 'product', 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'product-ean', 'value' => 123, 'compare' => '=', ...


0

This is the most simple and currently working solution. None of the above worked for me. It is tested and working with Wordpress 5.3.1 . Place the following code in your functions.php file to hook into posts_clauses filter. /** * Include meta fields in search * * @author Mindaugas // meevly.com * @link https://meevly.com/services/custom-wordpress-...


0

I've spent an hour searching for a solution and there was nothing that works so I had to write the solution on my own. It is tested and working with Wordpress 5.3.1 and is the only solution that solves this problem I could find on the internet. Place the following code in your functions.php file to hook into posts_clauses filter. /** * Include meta ...


0

This worked for me. 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'colors', 'compare' => 'NOT EXISTS' // doesn't work ), array( 'key' => 'colors', 'value' => 'blue' ) )


Top 50 recent answers are included