WordPress.org

Ready to get started?Download WordPress

Forums

formatting post titles in category view (9 posts)

  1. planetphillip
    Member
    Posted 9 years ago #

    HI,
    I'm using the code below, taken from another post, to display only the post titles when a user clicks a category.
    What I can't seem to work out is how to change the formatting of the titles in that view. Any changes I make to the storytitle effects the index page. I also would like to add the date next to the titles in the category view.
    Am I being really stupid and missing something obivous?
    TIA
    Phillip
    <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>

    <div class="post">
    <h3 class="storytitle" id="post-<?php the_ID(); ?>">" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></h3>
    <?php if (!$cat){?>
    <div class="storycontent">
    <?php the_content(); ?>
    </div>
    <div class="meta"><?php _e("Filed under:"); ?> <?php the_category() ?> — &amp;nbsp; <?php the_author() ?>&amp;nbsp; <?php edit_post_link(); ?></div>
    <div class="feedback">
    <?php wp_link_pages(); ?>
    <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
    </div>
    <?php include(ABSPATH . 'wp-comments.php'); ?>
    <?php } ?>
    </div>
    <?php endforeach; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    <?php endif; ?>

  2. carla
    Member
    Posted 9 years ago #

    Sounds as if there's a small error in your stylesheet wrt the class for "storytitle". Feel free to post the code here, and we'll see what we can do to help. :)

  3. planetphillip
    Member
    Posted 9 years ago #

    Carla,
    I'm not sure why you think there's an error in the stylesheet but here is the relevant section:
    h3 {
    /*float: left;*/
    color:#7093B8;
    margin: 0 0 0 0;
    padding: 0;
    font: bold 18px Helvetica, Arial, Verdana, sans-serif;
    }
    h3 a{
    color:#7093B8;
    text-decoration:none;
    }
    h3 a:hover{
    color:#0000FF;
    }

    complete style sheet here:
    http://www.planetphillip.com/style.css
    Just to clarify, the formatting on the index page is exactly how I want it, it's the category page I want changed.
    Examples:
    http://www.planetphillip.com/test.php (looks OK to me)
    http://www.planetphillip.com/test.php?cat=1 (Doesn't look good, need to make post title smaller and closer together plus add date)
    TIA
    Phillip

  4. Mark McKibben
    Member
    Posted 9 years ago #

    Umm, why not change the code in your category view to use something like storytitle2 as the ID on the titles and setup that new selector in your CSS with whatever settings you want?

  5. planetphillip
    Member
    Posted 9 years ago #

    Because the code you see is all of the code that relates to the index page and the cat page.
    The only difference I can see is the <?php if (!$cat){?> the rest is the same. I don't have seperate code for index and cat.
    Any changes I make to the code in my first post effects ALL pages. If I make a new style, say storytitle2, where do I put it so that it only effects the cat pages?
    I hope that makes sense.
    Thanks for the suggestions so far, please keep em coming.
    Phillip

  6. Mark McKibben
    Member
    Posted 9 years ago #

    I still think I'm missing something in what you're saying here, but it sounds like you've got 2 files index.php and cat.php. And you want the cat.php to display the story title differently than how the index.php displays it. Assuming that's correct then in your cat.php where ever it says class="storytitle"; change that to class="storytitle2" and then update your CSS file to include whatever settings you want for the cat page's storytitles.

  7. TechGnome
    Moderator
    Posted 9 years ago #

    Nope, it's one page, I see what's going on... will take me a few to set up an example....
    TG

  8. planetphillip
    Member
    Posted 9 years ago #

    Thanks for sticking with me.
    I only have one file: index.php
    The code I posted replaced code on the default index page.
    You can view it here:
    http://www.planetphillip.com/test.phps
    I would be comfortable if I had two files but because it's one I can't figure out what to do. Perhaps the category page just inherits the H3 heading style and I either have to use it or forget.
    TIA
    Phillip

  9. planetphillip
    Member
    Posted 9 years ago #

    OK, took a few failed attempts to implement but it seems to work.
    I'll now play around with the CSS to get it looking better.
    Thank you so much.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.