WordPress.org

Ready to get started?Download WordPress

Forums

Different introductory paragraph and/or images for each category (15 posts)

  1. glenv
    Member
    Posted 6 years ago #

    I have a WordPress Blog http://www.weddingstrategies.com that I have already prepared individual introductory paragraph's for each category index page. So say I have 10 categories I will have 10 separate intro paragraph's - each with it's own. I prefer not to post them as a post and sticky them since I want them to look like clean paragraphs.

    Can it be done? I would also like to be able to do the same thing in regard to adding a different picture at the top of each category index page.

    Thank you!

  2. moshu
    Member
    Posted 6 years ago #

    OK, just to make sure we are talking the same language: we call it "category archives".
    The simplest way to solve it, using Category_Templates. You can have one (category.php) with 10 Conditional_Tags in it, or you can have ten (category-1.php, category-2.php...) with their own 'paragraph/text'.

  3. glenv
    Member
    Posted 6 years ago #

    Ok, this makes sense. It appears when they created my site the category theme is using the "archive.php" - that is normally correct anyway right?

    So as an example lets say the "ID" of one category (although nowhere does it call it a category) is "26"

    According to the Category Templates doc you referred to above, I would create a category template called "category-26". My question - should it really be names "archive-26"?

    Also, am I too conclude from the paragraph I pasted below that it will first search that "archive-26" template over the remaining

    category.php
    archive.php
    index.php

    (see below)

    "In the case of categories, the hierarchy is fairly simple. For instance, suppose the ID number of the Category in question is 6. The Template Hierarchy specifies that WordPress will use the first Template file it finds in your current Theme's directory from the following list:

    category-26.php
    category.php
    archive.php
    index.php "

  4. moshu
    Member
    Posted 6 years ago #

    I will start with what you pasted at the end... seemingly there is a typo there! If the category ID# is 6, then WP will look for
    category-6.php
    category.php
    archive.php
    index.php

    And no, WP doesn't understand "archive-26" or whatever number!
    Your theme is using archive.php to display your category listings because it did not find a category-26.php or category.php file, so it goes to look for the next in the list. Don't invent anything like archive-26.php, there is never mentioned anything like that in the Codex!

  5. MichaelH
    Member
    Posted 6 years ago #

    Another option, is to write each paragraph as a Page, make the Page Status = Draft, then use query_posts with the pagename= parameter where your page name is like 'ParagraphForCategory5'

    Something like this before your loop in your Category Template.

    <?php
    $temp_query = $wp_query;
    $pagename = 'pagename=ParagraphForCategory' . intval( get_query_var('cat') );
    query_posts($pagename);
    while (have_posts()) : the_post();
    the_content();
    endwhile;
    $wp_query = $temp_query;
    ?>

    Of course the 5 in 'ParagraphForCategory5' is your Category 5.

  6. moshu
    Member
    Posted 6 years ago #

    Michael,
    Kaf's get_a_post plugin does the same :)

  7. glenv
    Member
    Posted 6 years ago #

    Ok, I am getting closer:

    Please view my code I have placed on my category-26 page:

    http://weddingstrategies.com/category/ceremony-reception/style

    Here is what I have placed as code in the template

    ========
    <BR />

    <table
    align="right"
    border="0"
    padding-left:10px; ><tr>
    <td>
    <img src="http://weddingstrategies.com/wp-content/uploads/2007/09/style.jpg" /></td>
    </tr>
    </table>

    We all have a style in which we feel most comfortable. Whether it is extravagant or simple, it is what suits each of us as an individual. When it comes to your wedding, you don’t want to change your style and try to be something, or someone else. Use the following articles to help make choosing a style come more easily to you!

    ========

    Any guru's able to help me get it to work so all the posts wrap around the picture? and I get 10 px padding only on the left and right of the picture?

  8. MichaelH
    Member
    Posted 6 years ago #

    Thanks moshu.

    Here's the link just in case:
    http://guff.szub.net/2005/01/27/get-a-post/

  9. glenv
    Member
    Posted 6 years ago #

    Changed it this and still same problem:

    <BR />

    <p><img src="http://weddingstrategies.com/wp-content/uploads/2007/09/style.jpg" style="padding-left: 10px; padding-right: 10px" align="right" />We all have a style in which we feel most comfortable. Whether it is extravagant or simple, it is what suits each of us as an individual. When it comes to your wedding, you don’t want to change your style and try to be something, or someone else. Use the following articles to help make choosing a style come more easily to you!</p>

  10. moshu
    Member
    Posted 6 years ago #

    I am not a table guru... so that might be difficult. You don't really need tables to have the right HTML! On the contrary...
    (and in XHTML everything should be lower-case, like <br />

    Well, the posts section is unlikely to get wrapped around the pic - they are in a different block level element.

    The most you could do: increase the paragraph and decrese the pic...

    And the code should be:
    in the category-26.php

    <div id="kopf">
    
    <img src="http://weddingstrategies.com/wp-content/uploads/2007/09/style.jpg" />
    
    We all have a style in which we feel most comfortable. Whether it is extravagant or simple, it is what suits each of us as an individual. When it comes to your wedding, you don�t want to change your style and try to be something, or someone else. Use the following articles to help make choosing a style come more easily to you!
    </div>
    <br class="clearer" />

    in the stylesheet:

    #kopf img {float: right;
    margin: 0 10px;
    }
    .clearer {clear:both;}

    (You can call that div whatever you want...)

  11. glenv
    Member
    Posted 6 years ago #

    thanks, yeah I think I am going to have to settle for the text and let the picture just go for now.. I'm happy to at least get that much!

    Thank you!

  12. glenv
    Member
    Posted 6 years ago #

    One more note: You know what would be a great resolution to this is if somehow when you create a new category that the "optional description" had an option to show that description under the Category Title of the page. This seems like a real easy solution and seems it would be greatly rallied around since I gotta believe many people would like to have an easy way of giving an introductory description to each individual category index page. One thing that would need to be remembered though is I would only want to have ot show on the forst page of the category.

  13. moshu
    Member
    Posted 6 years ago #

    Even better solution is... to search and read the documentation :)
    http://codex.wordpress.org/Template_Tags/category_description

    To be displayed only on the first page of the catgeory archive you will need some magic with the conditional tags.

  14. glenv
    Member
    Posted 6 years ago #

    Very cool moshu..

    I am using:

    <div id="intro" class="post"><?php echo category_description(26); ?></div>

    See:
    http://weddingstrategies.com/category/ceremony-reception/style

    Is there a way that just one piece of code could be added to only the archive.php file and it call the appropriate description?

    Otherwise it seems I still need to create about 25 category-?

    Maybe I can't do this without making all the categories

  15. moshu
    Member
    Posted 6 years ago #

    I guess you may try:
    rename category-26.php to category.php - and edit it to have the description without the cat ID. Delete the numbered cat template(26) from the sever. See if it works...

Topic Closed

This topic has been closed to new replies.

About this Topic