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

the_post_thumbnail() based on the Post ID

I got the solution so self-answering the question for future users/visitors. Hope it will help someone. I think this won’t be able to generate results based on the Post ID → the_post_thumbnail( ‘large’); However, this should work → <?php echo get_the_post_thumbnail($fpid, ‘large’); ?> (Above is succesfully tested) Other possibilities → <?php echo get_the_post_thumbnail($fpid, ‘thumbnail’); ?> … Read more

Categories PHP Tags functions, homepage, php, post-meta, single

Is it possible to store arrays in a custom field?

Yes you can, either by code: $demo = array(‘value1′,’value2′,’value3′); update_post_meta($post_id,’meta_key’,$demo); Or simply using the custom fields UI, add ass many values as you want one at a time and make sure they all have the same meta_key.

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

passing argument to get_template_part() or a better way to code

Why don’t you use a simple function with an argument to achieve that, the code is something like this: function wpse63585_event_list( $fresh = true ) { echo ‘<ul class=”event-items”>’; $yesterday = time() – 24*60*60; $compare = $fresh ? ‘>’ : ‘<‘; $args = array( ‘post_type’ => ‘wr_event’, ‘posts_per_page’ => -1, // show all posts ‘meta_key’ … Read more

Categories custom-field Tags custom-field, get-template-part, include, post-meta, templates

Use custom posts as taxonomy term meta replacement?

You can add taxonomy metadata, similar to add_post_meta and some examples of doing so include, Tutorial Walk-Through http://en.bainternet.info/2011/custom-taxonomies-extra-fields Taxonomy Metadata Class (improved version of above) http://en.bainternet.info/2012/wordpress-taxonomies-extra-fields-the-easy-way I have personally used this class myself which was also authored from a reputable member and moderator here at WPSE -> Bainternet, it did what it said on the … Read more

Categories custom-taxonomy Tags custom-taxonomy, post-meta

Get all posts from custom post type and insert in select input as metabox

(0. Retrieve the meta value with get_post_custom (in order to highlight the selected value in the select input).) Query posts with get_posts( array( ‘post_type’ => ‘services’, ‘post_status’ => ‘publish’ ) ) Loop through the results with foreach and build your select input. Hook into save_post (add_action(‘save_post’, ‘my_save_meta’) to store the selected value (with update_post_meta).

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

How can I display image metadata?

Because the credit data is saved in the attachment’s post meta, not the main post: $credit = get_post_meta( $post->ID /* Wrong ID! */, ‘credit’, true ); Instead you need to catch the ID of the inserted image: function attach_image_credit( $images ) { $return = $images[0]; // Get the image ID from the unique class added … Read more

Categories filters Tags attachments, filters, post-meta, the-content

Add options to featured image

You got it quite right, but with a few minor problems. First, please use a uniqe prefix for your functions and values – opacity or meta_save are quite generic and could be used by other authors. Second, the part where you get the meta opacity was missing, I added it for you – just retrieve … Read more

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

WooCommerce conditional meta query

The default relation for a meta query is AND, so when you have two conditions they will be treated as such: $meta_query[] = array( ‘key’ => ‘_stock’, ‘value’ => ‘0.000000’, ‘compare’ => ‘NOT IN’ ); $meta_query[] = array( ‘key’ => ‘_backorders’, ‘value’ => ‘no’, ‘compare’ => ‘!=’ ); Get all products with a _stock meta … Read more

Categories woocommerce-offtopic Tags meta-query, post-meta, woocommerce-offtopic

How to display multiple Post meta_key/meta_values by SQL query

change where clause with or SELECT P.ID, P.post_title, P.post_content, P.post_author, meta_value FROM wp_posts AS P LEFT JOIN wp_postmeta AS PM on PM.post_id = P.ID WHERE P.post_type=”post” and P.post_status=”publish” and ( meta_key = ‘job_title’ or meta_key = ‘company_email’ ) ORDER BY P.post_date DESC but this sql will return the same post in 2 row for your … Read more

Categories PHP Tags custom-field, php, post-meta, sql

Meta query interfering with orderby relevance

So after @Nicolai found that blurb in the WP source confirming that I can’t use multiple parameters in the orderby if I am ordering by relevance I had to go a different route. However, this route only works if I don’t care for pagination. There probably is a way to put it back, but I’m … Read more

Categories Database Tags database, meta-query, order, post-meta, pre-get-posts
Older posts
Newer posts
← Previous Page1 … Page187 Page188 Page189 … 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