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

Finding the page id

IDs always show in links in admin area, like /wp-admin/post.php?post=2164&action=edit There are also some plugins that simplify this, quick search came up with Simply Show IDs.

Categories post-meta Tags page-specific-settings, post-meta

how to get all post with the same post meta?

As simple as this: $the_posts_you_want = get_posts( array( ‘meta_key’ => ‘project_id’ ) ); foreach ( $the_posts_you_want as $post ) { // Do whatever you need in here… // Read further how to inspect the post object: http://wordpress.stackexchange.com/questions/13063/how-to-inspect-global-variables-in-wordpress // echo each meta key echo $post->whatever; // or save it into a new array for further processing … Read more

Categories post-meta Tags post-meta

Removing Post Meta from Category Pages?

try this: /** Customize the post meta function */ add_filter( ‘genesis_post_meta’, ‘post_meta_filter’ ); function post_meta_filter($post_meta) { if (!is_page()) { if (is_category()) $post_meta=””; else $post_meta=”[post_categories]”; return $post_meta; }}

Categories post-meta Tags post-meta

How to stop wp_postmeta from being called on archive and search pages?

add_filter(‘pre_get_posts’, ‘customize_query’); function customize_query($query) { if($query->is_main_query() && ($query->is_search() || $query->is_archive()) { $query->set(‘update_post_meta_cache’, false); $query->set(‘update_post_term_cache’, false); } } Then wordpress will make 2 less queries for those pages & then you can use the $wpdb object to write custom queries.

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

Custom meta field don’t give me numerical value

// Correct way to convert string to integer $begin = ’34’; $number = (int)$begin; var_dump( $number ); int 34 //Another correct way to convert string to integer $number = (int)get_post_meta( get_the_ID(), ‘begin’, true ); var_dump( $number ); int 34 //strops() = Find the numeric position of the first occurrence of needle in the haystack string. … Read more

Categories post-meta Tags post-meta

how do I set a schedule event to modify all posts’s meta value weekly or monthly?

wp_schedule_event() is what you are looking for. With this function you can create a cron jon that WordPress will axecute on the specific interval you configure. This function should be called only on plugin activation and the scheduled event should be cleared on plugin deactivation. For example: //Create the weekly and monthly interval add_filter(‘cron_schedules’, ‘cyb_cron_schedules’); … Read more

Categories post-meta Tags post-meta

wp_update_user isn’t instantly?

global $current_user; get_currentuserinfo(); if (isset($_POST[’email’])) { wp_update_user( array(‘ID’ => $current_user->ID, ‘user_email’ => $_POST[’email’]) ); unset($current_user); get_currentuserinfo(); //just in case } echo ‘<p>You’ll recieve a mail here: ‘ . $current_user->user_email . ‘</p>’; Now it should work, the problem was on the get_currentuserinfo() function, because it checks if the variable is already set and is an instace … Read more

Categories post-meta Tags post-meta

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

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
Older posts
Newer posts
← Previous Page1 … Page37 Page38 Page39 … Page51 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
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 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