Hi, I'd like to remove the author and date from one post only to be used as the welcome post. How can this be done?
Also how can I change the colour of the title of that one post?
Thanks
Hi, I'd like to remove the author and date from one post only to be used as the welcome post. How can this be done?
Also how can I change the colour of the title of that one post?
Thanks
You can test on the post title for any of the above requests within your templates. Examples:
Author/Date
<?php if( get_the_title() != "Welcome" ) : ?>
Posted by <?php the_author(); ?> on <?php the_date(); ?>
<?php endif; ?>
Note the use of != in the if() which is PHP for 'does not equal.'
CSS class assignment
<?php $title_class = ( get_the_title() == "Welcome" ) ? 'welcome-title' : 'post-title'; ?>
<h2 class="<?php echo $title_class; ?>"><?php the_title(); ?></h2>
This one is a bit more complicated. We're using what's called a ternary operator to choose between two values for $title_class. The operator evaluates the expression in the parentheses:
( get_the_title() == "Welcome" )
If true, $title_class will be set to 'welcome-title'; if false, 'post-title'. Then we output $title_class as the value for the h2 class attribute using the PHP echo command:
<?php echo $title_class; ?>
Thanks for the reply, but where does the code for the author/date go? I tried putting it in the main index template but it doesn't seem to be working.
Problem here is I do not know what the source for your theme's index looks like.
If you need such specific help you'll have to upload the source of the template to a shared location, say:
Reply back with the url you get for it.
This topic has been closed to new replies.