How to remove published date from RSS feed

Note that if you remove the <pubDate> tag from the rss2 feed, then it will become unvalid. So you don’t want to do that! If it’s empty: <pubDate></pubDate> then the feed will still not validate: > pubDate must be an RFC-822 date-time So that wouldn’t be an option either. If you want it static, for … Read more

How to display Last Updated date from the latest post for a category list

<?php // select all sub categories of parent cat with id ‘8’ $categories = get_terms( ‘category’, array( ‘orderby’ => ‘ID’, ‘parent’ => 8 ) ); // For each sub category find last post foreach ( $categories as $category ) { $args = array( ‘cat’ => $category->term_id, ‘post_type’ => ‘post’, ‘posts_per_page’ => ‘1’, ‘orderby’ => ‘date’, … Read more

How to stop a user from updating the post date

As @t-f pointed out in his comment to question, you have an error on checking current user capability: ‘delete_published_posts’. $post_author_id simply doesn’t exist. After that, for your scope probably is a better hookin the filter wp_insert_post_data instead of the action save_post: because this one run when the post was already saved / updated, so if … Read more

Keeping post_date same as the pending post_date on privately publishing the post

@Howdy_McGee is on the right track in his comment: by the time transition_post_status is fired, the post has already been updated (i.e., written to the db). What you need to do is hook into wp_insert_post_data, instead of transition_post_status, as follows: add_filter (‘wp_insert_post_data’, ‘mycpt_keep_pending_date_on_publishing’, 10, 2) ; function mycpt_keep_pending_date_on_publishing ($data, $postarr) { if ($data[‘post_type’] != ‘mycpt’) … Read more

Date, Time, and Timezones

What is the purpose of the timezone setting in the Admin -> Settings section? Since WordPress handles time zone on its own (separately from native PHP functionality) that is where the setting made and result is stored in options. Whenever anything that works with timezones needs to happen, the time zone setting is retrieved and … Read more

Post date vs. event date in WordPress

I’m not sure about a plugin, but you can definitely add custom meta that allows you to set the event date, or even an event daterange (my preferred way of handling this is an event date and a duration, cuts down on calculations in the backend and is generally easier to understand, but ymmv). This … Read more

Query posts from current year

You just need get current date and add it on data_query in wp_query, Look this: <?php $getdate = getdate(); $args = array( ‘date_query’ => array( array( ‘year’ => $getdate[“year”] ), ), ); $query = new WP_Query( $args ); ?> and then use loop: <?php if ( $query->have_posts() ): while ( $query->have_posts() ) : $query->the_post(); the_title(); … Read more