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

Exclude from the query posts with meta_key and meta_value

I think you’ll need to add a posts_join filter, to join the posts and postmeta tables. This link should be helpful: http://codex.wordpress.org/Custom_Queries, in particular this piece of example code: add_filter(‘posts_join’, ‘geotag_search_join’ ); add_filter(‘posts_where’, ‘geotag_search_where’ ); function geotag_search_join( $join ) { global $geotag_table, $wpdb; if( is_search() ) { $join .= ” LEFT JOIN $geotag_table ON ” … Read more

Categories functions Tags functions, post-meta, query-posts

Non-Closing PHP Query in WordPress Loop

Try <?php wp_reset_query(); ?> after each function. See Function Reference/wp reset query « WordPress Codex

Categories PHP Tags custom-field, multi-language, php, post-meta

How can I modify RSS item titles to be either the title or a custom meta field?

Something like this (not tested): add_filter(‘the_title_rss’, ‘custom_feed_title’); function custom_feed_title($title) { $headline = get_post_meta(get_the_id(), ‘headline’, true); if (!empty($headline)) return $headline; return $title; }

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

How to test the outcome of a wpdb query?

First of all, you should look into using WP_Query for this: http://scribu.net/wordpress/advanced-metadata-queries.html Secondly, to see the results, just do a var_dump() before the return: echo ‘<pre>’; var_dump( $data );

Categories post-meta Tags post-meta, wpdb

Is there a way to exclude posts based on meta_values?

I met the same problem before. I tried to use meta_query parameter in the query argument, but didn’t succeed. The code I tried to use looks like this: $software = array( ‘post_type’ => ‘software’, ‘meta_query’ => array(‘key’ => ‘legacy’, ‘value’ => 1, ‘compare’ => ‘!=’) ); query_posts($software); But the problem is this query also excludes … Read more

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

wrap text around custom fields array

if( !empty($custom_fields) ) { $output=””; foreach( $custom_fields as $key => $value ){ foreach( $value as $val ){ $output .= “{“.$key.” : ‘”.$val.”‘},”; } } echo $output; }

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

$_GET & $post_ID

Once you’re in the function that actually prints the html for the metabox, the global $post object should always be set the to current post. Is there a specific reason that you need to know the post_id during init?

Categories metabox Tags metabox, post-meta

Can I access a post meta field before the loop?

You can get it by calling global $wp_query and assigning post->ID to a variable. <?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, ‘top-headline’, true); ?>

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

Should I save this mulit dementional arary as one post meta?

In most cases its better to store the meta as a single array and in that save database queries. The only down side to storing the data as an array is it’s nearly impossible to query based on sirealized data. So my rule is if i need to query based on that data the it … Read more

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

Time & Date on Post – Time Ago Custom Function

$mytimestamp = date(get_option(‘date_format’), strtotime($date)) . ‘ at ‘ . date(get_option(‘time_format’), strtotime($date));

Categories post-meta Tags array, date-time, options, post-meta, timestamp
Older posts
Newer posts
← Previous Page1 … Page114 Page115 Page116 … 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