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.
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.
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
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; }}
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.
// 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
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
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
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.
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
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