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

help to decipher wp metadata

What you’re referring to is serialized data. To save an array to MySQL the data is serialized upon submission, so the best way to read that data is to pull it out of the database with a function that unserializes it, which WordPress does for you. More details So somewhere in a theme or plugin … Read more

Categories post-meta Tags post-meta, user-meta

wordpress get_post_meta / the_meta to output custom field value

You need to echo get_post_meta(), like this: <div class=”button”> <a href=”https://wordpress.stackexchange.com/questions/48542/<?php echo get_post_meta($post->ID,”Button’, true); ?>”> <img src=”<?php echo get_template_directory_uri() . ‘/images/button.png’; ?>” alt=”link” /> </a> </div>

Categories custom-field Tags custom-field, post-meta

Excluding posts by meta, and also keeping posts without the meta

I think I managed to solve this. What I did was to add the following in my functions.php file: add_filter( ‘posts_where’, ‘exclude_my_posts’ ); function exclude_my_posts( $where ) { global $wpdb; // For the front page. Hide posts with “efter15” set to “Ja”, and only show posts with “show_on_front_page” set to “Nej” if (is_front_page()) { return … Read more

Categories filters Tags filters, meta-query, post-meta, query

getting the post_id from the post_meta

You should use WP_Query in this case … $my_query = new WP_Query( array( ‘meta_key’ => ‘XYZ’, ‘meta_value’ => ‘ABC’ ) ); $post_ids = array(); while ( $my_query->have_posts() ) { $my_query->next_post(); $post_ids[] = $my_query->post->ID; } wp_reset_postdata(); … and read on here.

Categories post-meta Tags post-meta

Custom posts and get_post_meta in {$post_status}_{$post_type}

This is how I managed to fix it, Thanks to Stephen Harris. add_action(‘save_post’, ‘parse_csv’, 10, 2); function parse_csv($post_id) { $_pid = $post_id; // Autosave, do nothing if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; // AJAX? Not used here if ( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) return; // Check user permissions if ( … Read more

Categories hooks Tags hooks, post-meta

Is there a way to add a link with add_post_meta?

I don’t think spaces are allowed in $meta_key. Try to change ‘Author Email’ to ‘author_email’. Also, if you don’t want ‘author_email’ to be visible in Custom Fields metabox, prepend it with underscore: ‘_author_email’. Unfiltered link as custom field value can also mess this metabox.

Categories plugin-development Tags plugin-development, post-meta

Say I have a tech blog, how best would I store technical specs for a phone, if i use custom post types

i would go with custom post types with custom fields for each type. This will allow you or your client a super simple way to add, edit, delete, etc fields of each phone or the phone in general from your WP install. If you don’t feel like programming it, i have used a couple plugins … Read more

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

How can I add/update post meta in a admin menu page?

You will need to use an Ajax function. Which requires javascript to send the form data to your php Ajax function which you can use to run update_post_meta(); Example: Form Html: <form> <input id=”meta” type =”text” name=”2344″ value=”<?php echo esc_html( get_post_meta( 2344, ‘_your_key’, true) ); ?>” /> </form> Javascript: jQuery(document).ready(function() { jQuery(“form”).submit(function() { var post_meta … Read more

Categories custom-field Tags add-menu-page, admin-menu, custom-field, post-meta

Check for page template on save_post hook

You can check the request value, before save and get an hint via wp_die() add_action( ‘save_post’,’wpse46583_save’, 10, 2 ); function wpse46583_save( $post_id, $post ) { // verify this is not an auto save routine. if ( defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE ) return; // You should check nonces and permissions here if ( ! current_user_can( ‘edit_page’, $post_id … Read more

Categories save-post Tags post-meta, save-post

Randomizing Post Links Outside of Loop – No Author or Date

The key to this is covered on the get_posts codex page: Access all post data using the setup_postdata function: foreach ( $rand_posts as $post ) : setup_postdata($post); Regarding the_date, see the note about multiple instances on a page: SPECIAL NOTE: When there are multiple posts on a page published under the SAME DAY, the_date() only … Read more

Categories post-meta Tags author, date, date-time, post-meta
Older posts
Newer posts
← Previous Page1 … Page78 Page79 Page80 … 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