Forums

Switch Off date In A Particular Category (21 posts)

  1. Anonymous
    Unregistered
    Posted 7 years ago #

    Hi,
    Can someone please tell me how I disable display of the date & time of posting, category filed under, the author and the 'edit this' link for just one particular category e.g. 'about'
    Thanks

  2. Anonymous
    Unregistered
    Posted 7 years ago #

    Thanks, but I tried that & it didn't work.
    When it comes to PHP, I know nothing, so need someone to tell me exactly what changes to make. any offers?
    The category is 'about'

  3. Beel
    Member
    Posted 7 years ago #

    It has been awhile since I worked in 1.2 so in_category may be a 1.3 function. If you don't want to search here or at php.net and learn how to do conditionals, I am sure someone will post the exact code for you in time. Sorry, but I've gotta run.

  4. Kafkaesqui
    Moderator
    Posted 7 years ago #

    Yep, in_category is only in 1.3, Beel.
    Anon, try something like the following:
    <?php if (the_category_ID('') != X) the_date(); ?>
    Not pretty, but it should provide the right conditional check on the category of your posts.

  5. Anonymous
    Unregistered
    Posted 7 years ago #

    Thanks Kafkaesqui. I tried your suggestion, but that didn't work either....unles I'm implementing it incorrectly that is. Should that go before or after or instead of the original call for the date and should I just be putting the category name in between the single inverted commas or doing something else as well? Please bear in mind I don't have a clue what I'm doing!
    Alternatively, does anyone else have any suggestions?
    Thanks

  6. charle97
    Member
    Posted 7 years ago #

    in_category is in 1.2. matt coded it for his asides.

  7. Anonymous
    Unregistered
    Posted 7 years ago #

    Great, so it's in there....how do I use it? Anyone????

  8. Anonymous
    Unregistered
    Posted 7 years ago #

    Yes, put where do I place it in the index file ? I'm presuming somewhere here:
    <div id="content">
    <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
    <?php the_date('','<h2>','</h2>'); ?>
    But where exactly? Before or after or instead of the existing line about the date?
    Thanks.

  9. Anonymous
    Unregistered
    Posted 7 years ago #

    OK Tried again. It kind of works but it removes the horizontal bar underneath the date.
    How can I loose the date but keep the horizontal bar for that category (and have all the other categorys behave normally)?

  10. Anonymous
    Unregistered
    Posted 7 years ago #

    I have no idea - I see an <h1> tag and an <h2> tag, I have no idea what either one does or how to set them seperately? Can you explain please??

  11. Kafkaesqui
    Moderator
    Posted 7 years ago #

    Anon, look in the wp-layout.css file (will be in WP's root folder with index.php). That's where you'll find all the formatting goodies in your page. If you're confused about any of what you find there, you'll trip over css gurus hereabouts...
    Hmm, couldn't get in_category() to work on my 1.2 setup when it was referred to me a few back, though worked fine in 1.3. Go figure.

  12. Beel
    Member
    Posted 7 years ago #

    Anon: There is no way for us to know what you are talking about or what causes it (horizontal bar) without seeing it for ourselves. You'll either have to post a link to your blog or figure it out for yourself.

  13. Anonymous
    Unregistered
    Posted 7 years ago #

    Not mine, but same template:
    http://www.alexking.org/software/wordpress/styles/sample.php?wpstyle=dots
    Look beneath the header & you'll see 1/20/2004 immediately below that you'll see a thin green horizontal line. That's the horizontal rule I'm talking about. I want to keep that rule/line but loose the date on one particular category.
    Below that you'll see the headline "wordpress 1.0.1 released"
    and below that the line "filed under wordpress - Alex King @ 9.43pm" - I would also like to loose this "filed under" line for that particular category.
    Just under the "filed under" line, there is a vertical bar that travels downeards parallel to the left hand side of the text of the story. I'd like to keep that line.
    At the bottom of the story is a "comments" permalink that I'd like loose for a particular category too.
    & finally, I'd really like to do that for 2 particular categories, not just 1.
    ...pauses for breath
    Hopefully that's clear. If you can tell me how, i would be very grateful.

  14. Beel
    Member
    Posted 7 years ago #

    The line is set in the css for <h2> so:
    <h2><?php if (!in_category('X')) the_date(); ?></h2>
    As for the rest, obviously you will have to use that same conditional as above for the items you do not want to show for that category.
    <?php if(!in_category(X)) {
    echo "filed under: "
    blah-blah-blah;
    } ?>
    or
    <?php if(!in_category(X)) { ?>
    filed under: blah-blah-blah
    <?php } ?>

  15. Anonymous
    Unregistered
    Posted 7 years ago #

    I know the blah-blah-blah is blah-blah-blah to you, but it's not to me. Any chance you could tell me exactly what goes in place of the blah-blah-blah?
    Thanks.

  16. Anonymous
    Unregistered
    Posted 7 years ago #

    Ok, getting a bit complex for me. Here's the line that I want to alter:
    <div class="meta"><?php _e("Filed under:"); ?> <?php the_category() ?> — <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(); ?></div>
    I want to remove "filed under", the category, the author, the '@' & 'the time' if the category is '6' or if the category is '7'
    Please can you tell me what to replace the above line with?
    Thanks.

  17. Beel
    Member
    Posted 7 years ago #

    <?php if ((!in_category('6')) && (!in_category('7'))) { ?>
    all that junk you listed above
    <?php } ?>
    If you wanna get funky with the coding of display, you are going to have to start boning up on php! There are plenty of beginner PHP sites out there.

  18. Anonymous
    Unregistered
    Posted 7 years ago #

    Thanks!
    Which PHP sites would you suggest?

  19. Anonymous
    Unregistered
    Posted 7 years ago #

    Code didn't work???

  20. Anonymous
    Unregistered
    Posted 7 years ago #

    This line works for the date:
    <h2><?php if ((!in_category('6')) && (!in_category('7'))) the_date(); ?></h2>
    The only problem is it breaks the layout, shifiting everything in the left column into the centre?????

  21. Anonymous
    Unregistered
    Posted 7 years ago #

    Have tried again starting from scratch with a virgin index.php page and have found that the following code now works perfectly: <h2><?php if ((!in_category('6')) && (!in_category('7'))) the_date(); ?></h2>
    Thanks for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.