• My theme uses the following code in single.php to display the post date before an entry:

    <div class="postmetadata">Posted in <?php the_category(', ') ?> | <?php the_time('F jS, Y') ?></div>

    I have used display: none; under .postmetadata to disable this, which works well.

    However, I now have two categories – News and Themes (the slugs are lower case but the names have capital initials, if it matters). I want Themes to continue to have no post date, but I want the date to show once again for News. How can I achieve this?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Try:

    <div class="postmetadata">Posted in <?php the_category(', '); ?>
    <?php if( !is_category( 'Themes') || !in_category('Themes) ) :
    echo ' | ';
    the_time('F jS, Y');
    endif;?>
    </div>

    Thread Starter eggplant_casserole

    (@eggplant_casserole)

    Thanks for your quick reply.

    Well, the home page remains without a post date (as it should) and the post date shows in News. However, when I click on one of the posts in Themes, I get this:

    Parse error: syntax error, unexpected T_STRING in /wp-content/themes/totally-different/single.php on line 15

    *EDIT* I’ve just noticed, whilst the news page works, clicking on one of the news posts gives the above error, also.

    Argh! I’ve just spotted a missing ‘. Try:

    <div class="postmetadata">Posted in <?php the_category(', '); ?>
    <?php if( !is_category( 'Themes') || !in_category('Themes') ) :
    echo ' | ';
    the_time('F jS, Y');
    endif;?>
    </div>
    Thread Starter eggplant_casserole

    (@eggplant_casserole)

    Hi,

    Thanks for the correction! That certainly fixes the error! However, it doesn’t fix the issue. Themes continues to show the post date.

    Can you post a link to a page demonstrating this?

    Thread Starter eggplant_casserole

    (@eggplant_casserole)

    Sure!

    https://manicmikes.co.uk/news works as I want it to – it has the date on posts. Click on one of the titles, and that’s fine, too – I want those to show the date.

    Any of the pages on the left menu e.g. https://manicmikes.co.uk/50s-rock-n-roll-dance-party are posts in Themes, and shouldn’t have the date.

    The theme is Totally Different from sacramentoblogthemes.net.

    The News page is actually blank, but set as the posts page under reading settings. I have used Advanced Category Excluder to exclude Themes from these posts (Themes is ticked under Home on the ACE categories page).

    The links on the left are custom code in my sidebar.php:

    <li>
    		<h2>Themes</h2>
    		<ul>
    		    <?php
    			global $post;
    			$args = array( 'numberposts' => 10, 'offset'=> 0, 'category' => 3,
    			'order' => 'ASC' );
    			$myposts = get_posts( $args );
    			foreach( $myposts as $post ) :	setup_postdata($post); ?>
    			<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    			<?php endforeach; ?>
    		</ul>
    	      </li>

    Category 3 being Themes.

    Thread Starter eggplant_casserole

    (@eggplant_casserole)

    Does anyone have any ideas on this matter?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Showing posted date for single category only’ is closed to new replies.