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

Display post details by post ID

You can use get_post for that Example: <?php $post = get_post($id); //assuming $id has been initialized setup_postdata($post); // display the post here the_title(); the_excerpt(); the_post_thumbnail(); wp_reset_postdata(); ?>

Categories get-posts Tags frontpage, get-posts, post-meta

cleaning up safely wordpress wp_postmeta table

The only generic semi-automatic procedure I can think of would be to delete post meta where the post_id is invalid. SELECT * FROM {$wpdb->postmeta} as pm LEFT JOIN {$wpdb->posts} as p ON pm.post_id = p.ID WHERE p.ID IS NULL I wrote a SELECT and not a DELETE because I don’t trust that to work in … Read more

Categories post-meta Tags customization, optimization, post-meta, sql

Trying to get property of non-object error using get_post_meta()

$post is never set on init when I test this– function topSub( $Trunckvalue = null ) { global $post; var_dump($post); } add_action( ‘init’, ‘topSub’ ); The earliest hook I can find (by experimentation, not a canonical statement) is wp. Aditionally, $post is set on archive pages as well as “single” pages. On those archive pages … Read more

Categories post-meta Tags post-meta

Show future events based on custom field AND order by date

I found the actual issue so I thought I’d update. ACF documentation says to use $today = date (‘Ymd’) to compare dates but you really need to use current_time(‘Ymd’) so I removed the functions.php code that I added and fixed the problem rather than work around it. Here’s my query now $event1 = current_time(‘Ymd’); $args … Read more

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

Custom fields for custom post type

You need to add your own metabox for the custom post type created. You can use the action add_meta_boxes_{cpt_slug} add_action( ‘add_meta_boxes_’ . $cpt_public_slug, ‘adding_custom_meta_boxes’ ); add_action( ‘save_post’, ‘save_metabox’ , 10, 2 ); function adding_custom_meta_boxes(){ global $cpt_public_slug; add_meta_box( ‘plugin-site’, __( ‘Website’, ‘text_domain’ ), ‘cpt_form_site_Render’, $cpt_public_slug, ‘normal’, ‘high’ ); } function cpt_form_site_Render(){ global $post; $post_meta = get_post_meta($post->ID); … Read more

Categories custom-post-types Tags custom-field, custom-post-types, plugin-development, plugins, post-meta

Uknown meta entries in wp_postmeta

The best way to know which plugin was adding them is to search/grep your installation for occurrences of ‘wpAjax’ and “wpAjax”. If you find none (which is likely, since the oldest is 3 years old) safely delete from wp_postmeta where meta_key like ‘wpAjax%’, or something along those lines, if the latter statement might match something … Read more

Categories Database Tags customization, database, post-meta

Remove href tag from wp_postmeta in 34,000 posts?

Firstly, I would consider using one of WordPress’ wp_kses-like functions, instead of PHP’s strip_tags(). Secondly, query your posts with WP_Query or get_posts() with the fields parameter set to ids – seems like you don’t need more than that. Thirdly, split up your loop into steps that are effective and manageable. Because 34000+ posts will likely … Read more

Categories tags Tags post-meta, tags

Custom query, multiple custom keys

I’m not an SQL expert, but I would think you might have to JOIN twice to pick two distinct rows out of wp_postmeta: $featuredquery = ” SELECT wposts.* FROM $wpdb->posts wposts JOIN $wpdb->postmeta article_level ON ( wposts.ID = article_level.post_id AND article_level.meta_key = ‘article_level’ ) JOIN $wpdb->postmeta article_genre ON ( wposts.ID = article_genre.post_id AND article_genre.meta_key = … Read more

Categories post-meta Tags customization, post-meta, query-string

get_post_meta in WP_Query

If you will be pulling a lot of posts (or simply want to reduce the number of queries made), I’d recommend re-writing things a little bit. First, build a filter function to modify the query you are about to make. function filter_query_add_likes( $clauses, WP_Query $wp_query ) { if ( !is_admin() && !$wp_query->is_main_query() ) { global … Read more

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

Can’t publish custom post type – “You are not allowed to edit this post.”

The default for map_meta_cap is actually not false if you’re also passing in a capability_type of post or page, which you are. The following code is in WordPress Core’s post.php: // Back compat with quirky handling in version 3.0. #14122 if ( empty( $args->capabilities ) && null === $args->map_meta_cap && in_array( $args->capability_type, array( ‘post’, ‘page’ … Read more

Categories custom-post-types Tags custom-post-types, metabox, post-meta, publish
Older posts
Newer posts
← Previous Page1 … Page120 Page121 Page122 … 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