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

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

get_post_meta remains empty while looping all menu items and using the ID

You are sending the ID of the menu item not the ID of the page try using url_to_postid() like this: <?php $array_menu = wp_get_nav_menu_items(‘header-menu’); $menu = array(); foreach ($array_menu as $m) { if (empty($m->menu_item_parent)) { ?> <h4><a href=”https://wordpress.stackexchange.com/questions/257249/<?php echo $m->url;?>”><?php echo $m->title;?></a></h4> <p> <?php global $wp_query; $pageID = url_to_postid( $m->url ); echo get_post_meta($pageID, ‘meta_box_subtitle’, true); … Read more

Categories post-meta Tags post-meta

How can I get my iFrame to work with url from post_meta?

Almost every time when I post a question, I’m able to find the solution on the internet.. Sorry guys and girls for the spam! Solution <div class=”featured-img-blog”> <?php global $wp_embed; $get_video_url = get_post_meta(get_the_ID(), ‘video_url’, true); echo “<p align=center>” . $wp_embed->run_shortcode(”) . “</p>”; ?> </div>

Categories post-meta Tags iframe, post-meta

How add post_meta from user_meta?

Yo might need the user meta for this https://codex.wordpress.org/Function_Reference/get_user_meta You can get to it by including the post author as the user_id. So: get_user_meta($post->post_author, ‘meta_key’

Categories post-meta Tags post-meta

get_post_meta pagination

On a singular view, the current page number can be accessed with get_query_var(‘page’). You need to subtract 1 to get the corresponding array value. Note that the first page will redirect to the URL without page number, this is just a thing WordPress does. // get meta $metas = get_post_meta( $post->ID, ‘your_meta_key’, false ); // … Read more

Categories post-meta Tags post-meta

Does “update_post_meta” check if value is the same before updating?

update_post_meta() uses update_metadata() to update the post metadata, and if you call update_post_meta() without specifying the fourth parameter (i.e. $prev_value) — or that the value is empty, then yes, update_metadata() will check if the new value is the same as the current value in the database, and if so, the metadata will not be updated. … Read more

Categories post-meta Tags post-meta
Older posts
Newer posts
← Previous Page1 … Page38 Page39 Page40 … 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
  • 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