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

List all images from a single post meta value

You should reorganize the way you store the images: Make the uploaded files children of that particular post, do not put them in a post meta field. Then get all the images with get_children(). Look at the built-in handler for the shortcode for some examples. I should go like this: $args = array( ‘post_mime_type’ => … Read more

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

How to stop wp_postmeta from being called on archive and search pages?

add_filter(‘pre_get_posts’, ‘customize_query’); function customize_query($query) { if($query->is_main_query() && ($query->is_search() || $query->is_archive()) { $query->set(‘update_post_meta_cache’, false); $query->set(‘update_post_term_cache’, false); } } Then wordpress will make 2 less queries for those pages & then you can use the $wpdb object to write custom queries.

Categories post-meta Tags meta-query, optimization, post-meta

Retrieving an alt tag from a custom field

The following ought to be much closer to what you want to achieve: <div class=”imgHentry”> <a href=”https://wordpress.stackexchange.com/questions/74228/<?php the_permalink(); ?>” class=”goto-icon”> <?php the_post_thumbnail( ‘thumbnail’, array( ‘alt’ => get_post_meta( $post->ID, ‘alt_tag’, true ) ) ); ?> </a> </div>

Categories images Tags images, post-meta

Repeatable custom meta fields

I created and managed my own custom meta fields for years and I can tell you it was always a headache. I frequently came up against stumbling blocks like yours and ended up banging my fist against the wall. I’ve also worked on quite a few sites which had been flooded with plugins, sometimes so … Read more

Categories metabox Tags javascript, metabox, post-meta

Custom meta field don’t give me numerical value

// Correct way to convert string to integer $begin = ’34’; $number = (int)$begin; var_dump( $number ); int 34 //Another correct way to convert string to integer $number = (int)get_post_meta( get_the_ID(), ‘begin’, true ); var_dump( $number ); int 34 //strops() = Find the numeric position of the first occurrence of needle in the haystack string. … Read more

Categories post-meta Tags post-meta

My theme saves their custom post type’s metadata as a serialized array, how to access the keys?

That data is serialised PHP, if you pass in a PHP structure it will be serialised into a string. When you pull it back out, it’s de-serialised automatically, e.g.: $post_id = current post ID….. $data = get_post_meta( $post_id, ”, true ); To see the structure in a human readable form, use something like this: echo … Read more

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

Get specific custom field keys from a post and put into an array

There is no need to put them into an array. According to google’s documentation you should just separate out the various pieces of the address in the url like a standard (U.S.) formatted address. // Example taken from google’s docs: $state=”CA”; $street=”Mountain View”; $address=”1600 Amphitheatre Parkway”; function geocode_address($post_id) { $custom_fields = get_post_custom(); // just set … Read more

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

WP_query posts closest to todays date

try this, since you can pass multiple orderby values sparated by space. $args = array( ‘post_type’ => ‘post’, ‘numberposts’ => ’30’, ‘orderby’ => ‘post_date the_date’, ‘order’ => ‘DESC’ ); http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

Categories wp-query Tags post-meta, wp-query

Metadata for a taxonomy – is there any WordPress way of doing this?

why don’t you take a look at this I think it it is what you are looking for

Categories custom-post-types Tags custom-post-types, plugin-development, post-meta, taxonomy

How can I sort homepage by a meta value?

You probably also need: $query->set( ‘ignore_sticky_posts’, true ); That will prevent sticky posts from shuffling to the top. Maybe: $query->set( ‘posts_per_page’, -1 ); If you are getting too few posts. -1 means “all”. You can use that to change to a number other than what is set in the backend. A couple of notes: $query->set( … Read more

Categories custom-field Tags custom-field, post-meta, query, query-posts
Older posts
Newer posts
← Previous Page1 … Page151 Page152 Page153 … 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