Get old values for post before saving new ones
The post_updated action gives you both old and new values as arguments before the new values are saved: do_action( ‘post_updated’, $post_ID, $post_after, $post_before );
The post_updated action gives you both old and new values as arguments before the new values are saved: do_action( ‘post_updated’, $post_ID, $post_after, $post_before );
The Time Release plugin comes close, but has a fixed update period. The functionality is there, though, and I’d guess the portion of code that does the checking/updating could be hacked to use whatever (still-fixed) frequency you want without too much trouble. EDIT 2.16.12 Found a couple others that come much closer to Tumblr’s behavior … Read more
Digging through the code, it’s pretty straight-forward to find. First, look at the template used for product archives – /templates/archive-product.php. Among other things, it sets up the regular queries and begins building the markup of the page. But when it actually starts looping through each product, it delegates the work to /templates/loop-shop.php. This template is … Read more
Your best option is to get a random post author which is a user ID so here is a function to do just that: function get_random_author_wpa91320(){ global $wpdb; $id = $wpdb->get_var(” SELECT post_author FROM $wpdb->posts WHERE post_type=”post” AND post_status=”publish” ORDER BY RAND() LIMIT 1 “); return $id; } And once you have that function in … Read more
Late answer. has_archive applies only for the rewrite arguments. In Detail If has_archive is set to true, then the $archive_slug will get set to the rewrite[‘slug’] argument. If then a rewrite[‘with_front’] arg is set, then this one will get prepended. The result of this will then get added as rewrite rule: add_rewrite_rule( “{$archive_slug}/?$”, “index.php?post_type=$post_type”, ‘top’ … Read more
You can do this : add_action(‘admin_init’, ‘wpse_110427_hide_title’); function wpse_110427_hide_title() { if (current_user_can(‘subscriber’)) remove_post_type_support(‘post’, ‘title’); } This would hide title for subscriber. Replace ‘post’ with your custom post type
Post ID’s aren’t meant to be sequential. To number your posts sequentially, you’d have to use a meta field. There was discussion of this while back on this question: Change Permalinks Structure to a Sequential Number for Each Post? And the best answer for what you’re looking to do seemed to be a snippet of … Read more
Now that I have a better understanding of the issue, I would recommend using custom fields to sort your posts. You can have a custom field (e.g., “order”) and use it to indicate the order of your posts. You then need to use a custom query to order these posts when they are displayed. You … Read more
OK, so you have something like this: $new_tags = array( ‘tag1’, ‘tag2’, ‘tag3’ ); wp_set_post_tags( $post_ID, $new_tags ); If you want to add only tags that already exist, then you have to filter your tags array: $new_tags = array( ‘tag1’, ‘tag2’, ‘tag3’ ); $existing_tags = array(); foreach ( $new_tags as $t ) { if ( … Read more
When I look at WP::handle_404(), I think that the 404.php template will not be loaded, even if there are no posts, if: We are on the homepage It is a search It is a taxonomy term that exists, but has no posts attached to it (and it’s not paged) It is an author that exists, … Read more