All Questions

Tagged with
Filter by
Sorted by
Tagged with
0
votes
0answers
39 views

Get meta values from parent post and save in child post

I have a custom post type "E-Books" with two categories "E-Book Title" and "Chapter Page", and custom meta boxes (table of contents, etc). The E-Book post type uses one page template, and displays ...
0
votes
1answer
48 views

Reverse Cross-Sells (WooCommerce)

When you run get_post_meta( get_the_ID(), '_crosssell_ids',true); you get an array of all the products that the current product cross sells to. How do I reverse that? To get all the products that ...
0
votes
1answer
36 views

How to store multiple custom meta box

I am trying to store a multidimensional array of a Quiz where I dynamically add question box. But I am not able to figure out how to store dynamically added question box. The code is below function ...
0
votes
1answer
592 views

get_post_meta not work in php foreach

i have these codes : foreach ( $ids as $idss ) { echo get_post_meta($idss, 'IMDB', true); } i have search box with Form element that search and find all id ( $ids ) of searched word . i want to ...
0
votes
2answers
66 views

Output meta into arrays

I'm creating a loop which wouldn't output anything visible to the user, but needed to create a calculation later on. I have: // posts for the week mon-fri $week_array = array( 'posts_per_page' ...
0
votes
2answers
3k views

get_post_meta for Custom Post Type ( CPT )

Here's the TLDR: Is is possible to get all meta keys from a specific CPT without a database hit for each post? If so, how can I do this the Wordpress way? This seems like a simple thing to do ( at ...
4
votes
1answer
1k views

Check if user already visited this post today

I have a piece of code which measures a post popularity. How would I go about checking if user didn't already visited this post for past 24 hours? Do I need to set a cookie for user and for each post ...
0
votes
1answer
668 views

get_post_meta with variable

I’ve created a custom post type and a corresponding meta box for a site I’m developing. As there are several entries for similar 'products', some of the post metas repeat, albeit with a trailing ...
0
votes
1answer
544 views

Order a WP_Query by meta value where the value is an array

I have a WordPress custom query: $args = array( 'posts_per_page' => 2, 'meta_key' => 'pworks_popular_posts', 'paged' => $page_nr ); $query = new WP_Query($args); if($query->...
1
vote
1answer
5k views

Create a random unique 6 digit number as custom field for custom post type

I use the following function to create a random unique 6 digit number and save it in a custom post type meta field. I am unsure about the use of rewind_posts() inside a while loop. The idea is that ...
0
votes
1answer
1k views

Add a custom class to the body tag using custom fields

There are certain posts where I want to manually append a custom body class using custom fields. How do I go about it appending the class to the body tag when a certain custom field is added to a ...
0
votes
1answer
1k views

Define category ID using get_post_meta

I need to define the Category ID in my singles page through custom fields so that i can load a different category depending on the page. This is what i have so far and its not working. Any help would ...
0
votes
1answer
1k views

Order by in foreach

hello im getting post_id by using wpdb after that i wanna show postmeta(sd_l2) order by their value i uses this codes global $wpdb $top5_ov_performance = $wpdb->get_results("SELECT post_id FROM ...
0
votes
1answer
4k views

Hide a div when a custom field is empty

I am having trouble hiding a div when the input of a custom field is empty. This is the code I am using but can not seem to get it to work. The field that displays the content is _cmb_fe_wysiwyg &...
0
votes
2answers
390 views

Displaying values from related field - if empty shows current post type's link and title

I'm working with custom post types. In the post type awards I have a relationship field that links each award to a post from the post type project. I'm using the following code to return the values ...
1
vote
2answers
2k views

Why is my get_post_meta always empty

I made this action hook which will send an email to the users every time a new post in the custom post type "events" is made. function email_members($post_id) { global $wpdb; $usersarray = $wpdb->...
0
votes
1answer
222 views

get_post_meta is always empty when I use wp_mail

I made this action hook which will send an email to the users every time a new post in the custom post type "events" is made. function email_members($post_id) { global $wpdb; $usersarray = $wpdb->...
3
votes
5answers
13k views

Get meta_id along with meta_key and meta_value

Is it somehow possible to get_post_meta or get_post_custom and have meta_id returned along with the meta_value? For example: $data = get_post_meta( $post_id, 'my_key' ); // returns this: array( 0 =&...
0
votes
1answer
2k views

Post meta select input, if statement

I have created a meta box with a select input (drop down menu). It has a few values and I want to display different content depends on which value the user selects. I am just unsure how to display ...
0
votes
1answer
1k views

Wordpress stripping out custom field tags

I am using wordpress get post meta to store the value of a custom field into a variable. In this particular instance, It is actually grabbing the post's parent's custom field due to the $post->...