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

Only show meta on one post type on search results page

You didn’t provide any of the output code for the search results output, so what I’ve provided below is a guess based on how things ‘should’ work – chances are things will look different in your theme so you’ll need to sort out how to apply the same logic. In your search results template (content-search.php … Read more

Categories post-meta Tags post-meta, post-type, search

update_post_meta() is not saving the value

update_post_meta() is not saving the value

Categories post-meta Tags post-meta

How to access post meta on the first time a post is published

I usually handle this with save_post action. // We’ll use 1000, low priority (we’ll let other hooks to run first) add_action( ‘save_post’, [$this, ‘jackie_publish_post_hook’], 1000, 3 ); Then within your class: function jackie_publish_post_hook( $post_id, $post, $update ) { if ( $update ) return false; // Post already existed, don’t proceed // Do stuff } Or … Read more

Categories post-meta Tags post-meta

Update Images after edit via php

Update Images after edit via php

Categories PHP Tags images, php, post-meta

How to update custom fields when post is published?

Seems like you need to change your action to publish_post. publish_post only fires when a post is published. The callback function will only receive only one argument, the post id, with it you can do all your needed checks and update the meta as needed. By the way, update post meta doesn’t play well with … Read more

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

Adding Custom Metadata to my Archive/Posts page

try this (assuming your custom acf field is of type text), $source = get_field(‘source’, get_the_id());

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

Update Pages ONLY from Stage to Live (not products)

Update Pages ONLY from Stage to Live (not products)

Categories pages Tags pages, post-meta, staging

get_post_meta shortcode returns empty field

The shortcode callback function should always echo its output, not return it. Your code should be something like this: function wcal_abandoned_cart_id_shortcode_callback( $atts ) { $atts = shortcode_atts( array( ‘post_id’ => get_the_ID(), ), $atts, ‘wcal_abandoned_cart_id’ ); echo get_post_meta( $atts[‘post_id’], ‘wcal_abandoned_cart_id’, true ); } add_shortcode( ‘wcal_abandoned_cart_id’, ‘wcal_abandoned_cart_id_shortcode_callback’ ); If the output of your callback was HTML, besides … Read more

Categories plugins Tags custom-field, php, plugins, post-meta, shortcode

How to use multiple Meta Field from CPT as Post permalink

only the first meta field is used Yes, and it’s because the $new_slug contains just one meta which is maker. So if you want to add other meta like model and year, and have a slug that looks like <maker>-<model>-<year>, you can try my code below — just replace the $new_slug = get_post_meta($post_id,’maker’, true); in … Read more

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

Custom column on CPT not showing correct value when meta data not set

Hey so I was able to figure out something that worked. I don’t know if this is the best way but it worked for me. Please post an answer if you have a better idea. Basically I had to change the order in which the statements were in. The final code looked like this: function … Read more

Categories post-meta Tags columns, post-meta, variables
Older posts
Newer posts
← Previous Page1 … Page65 Page66 Page67 … 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