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

How to get custom post type to display post meta on archive pages?

Just change, <?php if ( ‘post’ === get_post_type() ) codilight_meta_1();?> to <?php if ( ‘post’ === get_post_type() || ‘reviews’ === get_post_type()) codilight_meta_1();?>

Categories post-meta Tags post-meta

Query post with meta_query where date is not in future

You might try adding a second meta_query that would look for anything without the meta key: $args = array( ‘post_type’ => ‘agenda’, ‘paged’ => $paged, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘datum_event’, ‘value’ => date(‘Ymd’), ‘compare’ => ‘<=’ ), array( ‘key’ => ‘datum_event’, ‘meta_compare’ => ‘NOT_EXISTS’, ‘value’ => ‘placeholder’ ), ), ); … Read more

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

Get page->parent’s name?

Once you’ve got the id of a post or page, use get_the_title($id) to get the page title (which is what I assume you mean by name) Codex Reference

Categories post-meta Tags post-meta

Trying to get file name

Your meta field contains the ID of the attachment, you need to fetch that ID, then get the filename using that attachment ID. $doc_id = get_post_meta( get_the_ID(), ‘pdf’, true ); $filename = basename( get_attached_file( $doc_id ) ); echo $filename;

Categories post-meta Tags post-meta

What Is meta_id In wp_postmeta?

meta_id in postmeta table is just an AUTO_INCREMENT id for the table, you can easily inspect that: So, your guess is correct, you can leave it. EDIT Avoid raw SQL statements and introduce $wpdb for SQL purposes. And for postmeta insertion you can see the following tutorial I found a best one: Reusable Custom Meta … Read more

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

trying to do if post meta !=0

The reason you have a problem is 0 is also considered equal to false, when the get_post_meta call returns false, it’s also the same as being equal to 0. if( !get_post_meta( $post_id, ‘some-non-existant-field’, true ) == 0 ) Would be the same as … if( get_post_meta( $post_id, ‘some-existing-field’, true ) == 0 ) ..the only … Read more

Categories post-meta Tags post-meta, rating

PHP Notice error (when on 404 page)

The 404.php template file is used for 404 errors: i.e. no posts found. Since there are no posts, there is no $post object. With no $post object, functions such as the_ID() are not available, and will return the error you’re observing. The fix: replace all instances of $post-derived data with static data. e.g. replace this: … Read more

Categories posts Tags 404-error, errors, post-meta, posts

Meta Box Only in CPT Edit Page, Not in Add New

Check the action of the current screen object for add: function wpd_add_meta_box() { $screen = get_current_screen(); if( ‘add’ != $screen->action ){ add_meta_box( ‘myplugin_sectionid’, ‘My meta box’, ‘myplugin_meta_box_callback’, ‘leads’ ); } } add_action( ‘add_meta_boxes’, ‘wpd_add_meta_box’ );

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

Query 2 meta key values and a category

The query value parameters can be set to true ( returns single result) or false ( an array). http://codex.wordpress.org/Function_Reference/get_post_meta For instance http://www.mattvarone.com/wordpress/query-multiple-meta-values/

Categories post-meta Tags post-meta

Why does get_post_meta not work with the posts page?

If your posts page is a static page selected under Settings > Reading > Front page displays, then get_queried_object_id() will return the ID for that page which you can use to fetch meta data. $check_meta = get_post_meta( get_queried_object_id(), ‘checkbox’, true ); $header_meta = get_post_meta( get_queried_object_id(), ‘header’, true ); $textarea_meta = get_post_meta( get_queried_object_id(), ‘textarea’, true );

Categories metabox Tags metabox, post-meta
Older posts
Newer posts
← Previous Page1 … Page161 Page162 Page163 … 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