Hot answers tagged

2

You're comparing strings. For dates this will only ever work out if you use a yyyymmdd format or similar.


2

For getting the posts related to each category you need to use get_posts( $args ) function and in $args you can add your category_id $args = array ( 'post_type' => 'post', 'category' => $cat_ID, 'post_status' => 'publish', ); $my_posts = get_posts( $args ); // return array of posts // storing all post ID in an array foreach( ...


2

You can calculate offset via paged and posts_per_page. E.g: $per_page = 6; $paged = get_query_var('paged') ? : 1; $offset = (1 === $paged) ? 0 : (($paged - 1) * $per_page) + (($paged - 1) * 2); $args = array( 'order' => 'ASC', 'paged' => $paged, 'offset' => $offset, 'orderby' => 'ID', 'post_type' => 'post', 'post_status' =&...


1

Up-voting Andy's answer, you should be comparing integers to get this working. strtotime() can turn any string to the time integer, which will be compared later to tell the difference and how many seconds passed until now ( time() ). Something like follows: $expired = ( ( time() - strtotime(get_the_date('Y-m-d H:i:s')) ) / DAY_IN_SECONDS ) >= 5; if ( $...


1

image_send_to_editor hook will handle when the image is sent to the editor. The problem will be that your editor may not work correctly when you modify the URL -- use with caution. save_post will allow you to modify the $post content on save. update_(meta_type)_metadata could be used to intercept when the meta data is saved.


1

Suppose you haven't modified anything to change the default content output, maybe this can help: add_filter('the_content', function($content) { $content = preg_replace('~^<p><img([^>]+)></p>~i', '', $content, 1); return $content; }, PHP_INT_MAX);



Only top voted, non community-wiki answers of a minimum length are eligible