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

Save re-arranged draggable post items to wordpress database

You would have to do the following to save the order data into the WordPress DB, Do a WordPress AJAX sending the data that you want to be stored in it. You can do it at every re-arrange event of the elements. Handle the AJAX call in PHP and either do an update_option() or an … Read more

Categories posts Tags html5, post-meta, posts

Set default Custom Post Meta Value

Use update_post_meta(), because if the meta key already exists add_post_meta() will do nothing if $unique is true and otherwise won’t update neither, while update_post_meta(), well, it will update the value of a existing field or create it, if it doesn’t exist yet.

Categories post-meta Tags actions, post-meta, save-post, wp-insert-post

Use WP_Query in shortcode

Your have two major issues here The string you are building is correct, but it gets overriden on each iteration of the loop, which at the end will only hold the info from the last post. You need to define your variable outside the loop and then concatenate your info to that variable across the … Read more

Categories PHP Tags php, post-meta, shortcode, wp-query

Query metas (and not : query posts by metas)

Look at the section on $wpdb->get_results(), it allows you to send distinct queries to the database, which is what it sounds like you are looking to do. So… // 1st Method – Declaring $wpdb as global and using it to execute an SQL query statement that returns a PHP object global $wpdb; $results = $wpdb->get_results( … Read more

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

Update post meta using pending_to_publish hook

I tend to make use of the transition_post_status hook as it gives you so much control over what you need to do. Be sure to check out the link for all available status options. What I specially like that the $post object is also passed to the hook, so you can target a specific post … Read more

Categories hooks Tags hooks, post-meta

Modify WP_Post before processing

There is a the_post hook which should let you modify the post object: function my_the_post_action( $post_object ) { // modify post object here } add_action( ‘the_post’, ‘my_the_post_action’ ); But the post data isn’t where your thumbnails are stored. They are associated via a post meta field. That is what you are going to have to … Read more

Categories posts Tags excerpt, filters, post-meta, post-thumbnails, posts

How to show Published date and/or Modified date

This function should be displaying both modified and published dates only if they differ. if ( get_the_time( ‘U’ ) !== get_the_modified_time( ‘U’ ) ) { $time_string = ‘<time class=”entry-date published” datetime=”%1$s”>%2$s</time><time class=”updated” datetime=”%3$s”>%4$s</time>’; } Dates are compared using timestamps and if they don’t match the string format is set to two <time> tags otherwise it’s … Read more

Categories post-meta Tags date-time, post-meta, wp-update-post

Add a meta value if admin , editor or any other user have open a post in edit mode

You can hook into the loading of any admin screen with add_action( ‘load-post.php’, ‘tbdn_post_screen’ ); function tbdn_post_screen() { // Check here whether you’re adding a post or // editing a post by seeing if $_GET[‘action’] // equals ‘edit’ then add your meta for post with // ID $_GET[‘post’] } Details of all of the admin … Read more

Categories post-meta Tags post-meta

Custom Post Status Transition Issues With Get Post Meta

The following worked for me. I hooked my meta saving and retrieving to the same action (post_transition_status), but with different priorities. //Save Your Custom Meta Meta, but hook it to transition_post_status instead of save_post, with a priority of 1 function save_yourpost_meta(){ global $post; if($post -> post_type == ‘your_post_type’) { update_post_meta($post->ID, “your_meta_key”, $_POST[“your_meta_key”]); } } add_action(‘transition_post_status’, … Read more

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

Where to hook my plugin’s action

Something important – when you create a new post the first thing WordPress does is an auto-save, so yes the first time the values should be empty. Perhaps that is what you are experiencing – I don’t see your full code, but I do see The plugin for the custom meta data is hooked in … Read more

Categories plugins Tags actions, database, hooks, plugins, post-meta
Older posts
Newer posts
← Previous Page1 … Page153 Page154 Page155 … 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