• I have a category page that currently displays a thumbnail, title excerpt and read more link for each post that has been entered under it. I was wondering if I could change the way that delivery is presented after a certain period of time. for example:

    Posts less than 2 weeks old show:
    Thumbnail, Title, Excerpt, Read More

    Posts older than 2 weeks show:
    Title (either linked or with Read More at the end)

    Both need to be on the same page.

    Any ideas?
    TIA
    ~Rat

Viewing 1 replies (of 1 total)
  • You could create two different template parts with the different presentations.

    Inside your loop you could put something like this:

    $time = 60 * 60 * 24 * 14; // two weeks in seconds
    $check = date_i18n( 'U' ) - $time; // todays date minus two weeks
    
    if( get_the_time('U') >= $check ) { // if the post is newer than or exactly two weeks old
    	get_template_part( 'list', 'newest' ); // use the template list-newest.php
    }
    elseif( get_the_time('U') < $check ) { // if the post is older than two weeks
    	get_template_part( 'list', 'oldest' ); // use the template list-oldest.php
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Change category excerpt style after certain date.’ is closed to new replies.