Where WordPress Stores The Custom Fields Values
In case you use native custom fields, you should look for them in wp_postmeta table (your table prefix can be different than ‘wp’).
In case you use native custom fields, you should look for them in wp_postmeta table (your table prefix can be different than ‘wp’).
Your third parameter of get_post_meta() is set to false. This means it will return an array. Even though you didn’t set a value for this custom field, it will still record an array element in the DB – so empty() will return false. Try switching to true for your third param. That should return an … Read more
I am assuming your custom post type is also “series”. Can you try this, it should work. $args = [ ‘post_type’ => ‘series’, ‘posts_per_page’ => -1, ‘meta_query’ => [ [ ‘key’ => ‘series’, ‘value’ => 19, ‘compare’ => ‘=’, ‘type’=>’NUMERIC’ ] ], ]; $posts = new WP_Query( $args ); or you can simple use: $args … Read more
Technically, third party plugins are off-topic for this site. However this is an easy one – in the Custom Fields page in the admin area, go into your field group. Scroll right down to the bottom and there’s a section allowing you to “hide” elements in the post. Select the “content” option here and you’re … Read more
I would not use custom fields or shortcodes for this functionality, I would look at filters. the_content filter and the loop_end action (just make sure that your theme uses while ( have_posts() ) in single post pages) comes to immediate mind here. These are two options which requires no modification of any of your files … Read more
numberposts doesn’t exist for WP_Query instead use “posts_per_page” => 1
You have a mismatch in your PHP tags. Use this: <?php $field_name = “text_field”; $field = get_field_object($field_name); ?> <table> <tbody> <?php if( isset($field[‘value’] ): ?> <tr> <th><?php echo $field[‘label’]; ?></th> <td><?php echo $field[‘value’]; ?></td> </tr> <?php endif; ?> </tbody> </table>
You have to consider that you’re dealing with substr() a string related function as the str in the function name indicates. That does mean that the parameter $string you give actually has to be of the type string. get_post_meta() on the other hand does just give you back whatever type you saved in the first … Read more
Try below code. $args = array( ‘fields’ => ‘ids’, ‘post_type’ => ‘numbers’, ‘meta_query’ => array( array( ‘key’ => ‘number’, ‘value’ => $number ) ) ); $my_query = new WP_Query( $args ); if( empty($my_query->have_posts()) ) { $post_id = wp_insert_post(array ( ‘post_type’ => ‘numbers’, ‘post_title’ => $name, ‘post_content’ => $details, ‘post_status’ => ‘draft’, ‘tax_input’ => $custom_tax, )); … Read more
I had the same problem. echo substr( $custom_field, 0, -6 ); echo str_replace(‘ ‘, ”, $custom_field); I think I solved it this way. echo substr( str_replace(‘ ‘, ”, $custom_field), 0, -6 );