• I’d like to style a post differently based on whether its this month, or any other previous month.

    I.e. something like…

    if (this_month) { get_template_part( 'content', 'post1' ) }
    else if (any_other prior_month) { get_template_part( 'content', 'post2') }

    How can I go about this?

    I found this snippet which is showing how to do a conditional statement based on time but don’t quite understand it:

    <?php $w_h = $w_d = 0; ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php
        if ( date('Yz') == get_the_time('Yz') ) {
            if (!$w_d++) echo 'Today<br />';
        } elseif ( date('Yz')-1 == get_the_time('Yz') ) {
            if (!$w_h++) echo 'Yesterday<br />';
        } else {
            echo the_date();
        };
    ?>
Viewing 1 replies (of 1 total)
  • Can you provide a url to the sit?. Often this can be accomplished with CSS. Providing the url will reveal the CSS classes and Id’s output in HTML .

    You may also want to review the default theme’s archive.php file and this on custom archive page templates:

    http://codex.wordpress.org/Creating_an_Archive_Index

    When creating the custom page template, you can include your custom styles…then add them…

    Note editing parent theme files is discouraged as such edits are lost on theme update. Consider using a Child Theme.

Viewing 1 replies (of 1 total)
  • The topic ‘style / different content posts based on month’ is closed to new replies.