Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

post-meta

Meta box data not saving

Have you noted that you are verifing that the post type is a page and that user can edit pages and posts? if ( ‘page’ == $_POST[‘post_type’] ) { if ( !current_user_can( ‘edit_page’, $post_id ) ) return; } else { if ( !current_user_can( ‘edit_post’, $post_id ) ) return; } It should be: if ( ‘ranch’ … Read more

Categories custom-post-types Tags custom-post-types, metabox, post-meta

If ACF meta_key has meta_value

While writing out this troubling question, alas! the answer did fall from the heavens and presenteth itself unto me: $meta = get_post_meta( get_the_ID(), ‘options’); if(in_array(‘blue’,$meta)) { echo “You’ve selected blue, punk!”; }

Categories post-meta Tags post-meta

Value of post meta dropdown is not showing in WordPress

the_ID() echoes its value, you can’t use it in that context. Change it to get_the_ID(). Many functions in WordPress follow this pattern- one function will print, while the same function with get_ prepended will return its value.

Categories custom-post-types Tags custom-post-types, post-meta

How to get single value from get_post_meta() array of values?

First, let met say that instead of echo, you should use var_dump or print_r for debugging. At first view, I see you are building a sequential array $current_history_array but you are trying to use it as associative array. $current_history_array[] = array ( current_time( “timestamp” ), $lastIP, $field, $value ); The above code generates a sequential … Read more

Categories post-meta Tags post-meta

Filtering by multiple conditions in the loop

You cannot mix array syntax and string syntax in the same argument. If you start with array syntax, you should stick with that, the same applies if you start with string syntax, then you should stick with string syntax. Because you are using post__not_in which is an array, you should stick with array syntax <?php … Read more

Categories wp-query Tags filters, loop, order, post-meta, wp-query

Echo custom post meta from options array

get_post_custom isn’t a great function if you’re trying to get values that are serialized, you have to unserialize them yourself. A better function is get_post_meta: $options = get_post_meta( $post->ID, ‘photo-artist_tfuse_post_options’, true ); echo $options[‘photo-artist_seo_description’];

Categories custom-post-types Tags custom-post-types, post-meta

Get posts ordered by meta data

I have achieved this in the past by using the following method. $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘post_type’ => ‘gtre’, ‘posts_per_page’ => 6, ‘paged’ => $paged, ‘meta_key’ => ‘price’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ); $pquery = new WP_Query($args); There shouldn’t be a need for the following in your … Read more

Categories post-meta Tags order, post-meta

How to get_post_meta in a shortcode in excerpt on archive pages

The do_shortcode function runs on the the_content hook: 402 403 add_filter(‘the_content’, ‘do_shortcode’, 11); // AFTER wpautop() https://core.trac.wordpress.org/browser/tags/4.1.1/src/wp-includes/shortcodes.php#L403 So, without seeing your theme code I am going to guess that your theme’s archive page is written in such a way that the do_shortcode function does not fire– possibly because it uses the_excerpt instead of the_content. If … Read more

Categories shortcode Tags post-meta, shortcode

Save Metabox Custom Field Value

I recommend not reinventing the wheel and looking at Reusable-Custom-WordPress-Meta-Boxes Even though this code is no longer supported it’s concise enough to be easily manageable. I use it and it works well. All you need to do is add the meta_box.php file to your functions.php and from then on use the predefined components: require_once(‘path_to/metaboxes/meta_box.php’); Then … Read more

Categories custom-post-types Tags custom-post-types, metabox, post-meta

Programmatically set thumbnail via URL using DOM and XPATH – Where to add ELSEIF

Ok I got it! Here is the code I used: add_action(‘publish_post’, ‘custom_auto_featured_image_publish_post’,10,2); function custom_auto_featured_image_publish_post($post_id, $post) { // get category of post ID $cat_detail=get_the_category($post_id); $cat_name = array(); foreach($cat_detail as $cd){ $cat_name[] = $cd->cat_name; } $custom_fields = get_post_custom($post_id); if(isset($custom_fields[‘original_guid’]) && !empty($custom_fields[‘original_guid’])){ $htmlURL = $custom_fields[‘original_guid’][0]; // try to load the webpage $dom = new domDocument; $imageURL = ”; … Read more

Categories post-thumbnails Tags post-meta, post-thumbnails
Older posts
Newer posts
← Previous Page1 … Page89 Page90 Page91 … Page204 Next →
+ More

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
Next Page »
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress