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

Adding meta data to an attachment post

So since attachments are post types, you should be able to assign them postmeta like any other post type. Using the update_post_meta function should get you where you need to be. update_post_meta( $attachment_id, ‘price’, $price ); http://codex.wordpress.org/Function_Reference/update_post_meta Then run your query based on a meta key. $args = array( ‘order’ => ‘ASC’, ‘post_type’ => ‘attachment’, … Read more

Categories post-meta Tags attachments, post-meta

get_post_custom()

What qualifies as custom field? Yes, a custom field is equal to post metadata, but be aware that some metadata is only for internal use (usually prepended with an underscore, for example _edit_lock. A more detailed look at the function The function get_post_custom() is actually just a wrapper for get_post_meta(): (wp-includes/post.php line 1764), but with … Read more

Categories post-meta Tags post-meta

Triple meta_key on custom SELECT query

Your Query is incorrect. To retrive meta values for triple meta_key you will need 3 different joins using posts meta on posts table. Check code below: // Example value $user_id = 1; // Calculate average post rating for user $ratings_query = $wpdb->get_results( $wpdb->prepare(” SELECT pmeta.meta_value FROM wp_posts LEFT JOIN $wpdb->postmeta AS pmeta ON (pmeta.post_id = … Read more

Categories post-meta Tags mysql, post-meta, select, wpdb

Using Advanced Custom Field (ACF) to insert meta description on each page

As mentioned in the comments, you are outside of the loop, so get_field will not know the ID. You can use the code below: <?php $meta_description = get_field(‘meta_description’, get_queried_object_id()); if(empty($meta_description)) { $meta_description = ‘This could be an interesting meta description’; } ?> <meta name=”description” content=”<?php echo $meta_description; ?> “/> If you use var_dump() in the … Read more

Categories post-meta Tags advanced-custom-fields, post-meta

Need help on creating If-statement for custom meta fields

This gets asked a lot so lets try and fully explain it. We can simply wrap it in an if statement and echo the value, for example, <?php if ( get_post_meta($post->ID, ‘genre’, true) ) : ?> <?php echo get_post_meta($post->ID, ‘genre, true) ?> ?> <?php endif; ?> But that is ugly, and why do 2 queries … Read more

Categories conditional-content Tags conditional-content, post-meta

Custom post type category not displaying in custom post type

Simply use get_the_term_list ex: echo get_the_term_list( $post->ID, Taxonomy_NAME, ‘<span class=”the-category”>’, ‘, ‘, ‘</span>’ ); just change Taxonomy_NAME to your category taxonomy name, if its the default category taxonomy then change it to ‘category’

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

Getting post meta data, while editing a post in wp-admin panel [closed]

Getting post meta data, while editing a post in wp-admin panel [closed]

Categories wp-admin Tags post-meta, wp-admin

Change post format using custom field

If the plugin works the way I think it does, you could try changing the priority of your gateway_set_post_format function being added to the save_post action. Your plugin may have a larger priority number which would make it fire later than yours. If the plugin does not change the custom field value until after your … Read more

Categories posts Tags custom-field, post-formats, post-meta, posts, xml-rpc

Displaying Meta Box Image

I don’t know exactly how that plugin works, and you have posted code that is probably missing context but you need to define $post_meta_data before running line: $custom_image = $post_meta_data[‘image’][0]; It seems that the plugin is using post meta so you should need something like this: <?php echo get_post_meta($post->ID, $prefix.’hjemmeside’, true); ?> But rewritten to … Read more

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

Copying Custom Meta Values from existing post to a duplicate post

Copying Custom Meta Values from existing post to a duplicate post

Categories custom-field Tags advanced-custom-fields, custom-field, post-duplication, post-meta
Older posts
Newer posts
← Previous Page1 … Page171 Page172 Page173 … Page203 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
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 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