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

Get thumbnail url of custom meta image?

You’ll have to use different function for that. wp_get_attachment_url returns a full URI for an attachment file and it doesn’t know what type of attachment it is. It makes no sense to generate thumbnail for .zip od .txt files, so this function doesn’t allow you to get thumbnail url. On the other hand, wp_get_attachment_image_url knows … Read more

Categories images Tags images, post-meta, thumbnails

Show post updated date instead of published

get_the_modified_date should do what you’re looking for. I am guessing that perhaps you are struggling a bit with the sprintf syntax. $date = sprintf( ‘<span>’ . __( ‘Posted’, ‘theme’ ) . ‘ <a href=”%3$s”><time class=”entry-date” datetime=”%1$s”>%2$s</time></a></span>’, esc_attr( get_the_date( ‘c’ ) ), esc_html( time_ago() ), esc_html( get_day_link( get_the_date(‘Y’), get_the_date(‘m’), get_the_date(‘d’) ) ) ); Let’s break it … Read more

Categories date Tags date, post-meta

Update CPT post meta with update_post_meta and cron job

Your problem is caused by your code… Let me comment it line by line, so the problem is more visible… global $post; // <- great, you use global $post variable $comp_args = array( // <- you set params for your query ‘post_type’=>’boat-company’, ‘posts_per_page’=>’-1′, ‘post_status ‘=> ‘publish’, ); $posts_array = get_posts( $comp_args ); // <- you … Read more

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

Get Current User Id Inside a Loop Returns 0 For a Shortcode

You have added get_current_user_id(); in single quote. please remove quote from ‘get_current_user_id()’;. function get_meta_value_by_meta_key(){ $author_id = get_current_user_id(); // do stuff to get user I $author_posts = get_posts( array(‘author’ => $author_id, ‘numberposts’ => -1 )); // needed to collect the total sum of views $counter = 0; // needed to collect the total sum of views … Read more

Categories PHP Tags author, php, post-meta, sql, wp-query

exclude posts with a specific custom field and value

The meta_query argument takes an array of arrays. ‘meta_query’ => array( array( ‘key’ => ‘city’, ‘value’ => ‘true’, ‘compare’ => ‘NOT LIKE’, ) )

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

Can’t check if a post has thumbnail adding filter to get_post_metadata()

Option 1: force featured image on all posts Use the save_post hook, which runs twice per “save” action if you have revisions enabled. You can verify it’s the final run by checking that there is $_POST data (it’s empty the first time around). add_action(‘save_post’, ‘wpse_force_featured_image’, 20, 2); function wpse_force_featured_image($post_id, $post) { // If this is … Read more

Categories functions Tags attachments, filters, functions, post-meta, post-thumbnails

Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?

Based on WordPress documentation for esc_attr function, it is returning a string value. So, If you need to have the integer value, you need using intval function. But, when you want to display that value or put it as part of markup, it doesn’t make sense. Escape functions are useful for outputting and printing values. … Read more

Categories plugins Tags escaping, php, plugin-development, plugins, post-meta

Insert Multiple Post with Same Publish Button

This should be possible, but it will take some work. As you found out, at the end of the wp_insert_post function, there is a hook save_post_{$post->post_type}, which you can do to additional stuff when a post with a certain custom post type is created. However, if you use this hook to create additional posts, the … Read more

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

INSERT ON DUPLICATE KEY UPDATE failes in postmeta table

By doing a SHOW CREATE TABLE on wp_postmeta, I got the structure of that table which included this: PRIMARY KEY (`meta_id`), So the key that MySQL can do the ‘insert or update’ on is the meta_id, which you’re not providing. Therefore in your query, it will always be added as a new row. EDIT: The … Read more

Categories post-meta Tags bulk-import, import, post-meta, query

How to use update_post_meta() function properly?

Directly accessing PHP files is not really how WordPress works. You currently have your code in a random PHP file that has no connection to WordPress. It’s probably throwing a Fatal error (Call to undefined function), which is why the next line doesn’t get executed. You said this code is in your theme, so I … Read more

Categories post-meta Tags post-meta
Older posts
Newer posts
← Previous Page1 … Page148 Page149 Page150 … 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