WordPress.org

Ready to get started?Download WordPress

Forums

Help with a Custom Template (7 posts)

  1. Matthew Meyer
    Member
    Posted 2 years ago #

    I need some help modifying the "A Page of Posts" template from the WordPress Codex: http://codex.wordpress.org/Pages#A_Page_of_Posts

    I want to make a template like this, but the one in the example uses the category name as its variable. I want to change that from category name to category ID, or category slug.

    The reason is that I am using a multilingual plugin, so that category name changes from language to language, and thus this template breaks when using translated names.

    Can someone teach me how to modify this template to look for category ID or slug instead of name? Thanks so much!

  2. Matthew Meyer
    Member
    Posted 2 years ago #

    *bump*
    Can nobody help?

  3. wspencer
    Member
    Posted 2 years ago #

    It's probably much easier to just make a category template page rather than do that.

  4. Matthew Meyer
    Member
    Posted 2 years ago #

    Thanks, I'll try that.

  5. wspencer
    Member
    Posted 2 years ago #

    and it apparently didn't let me post my link....

    http://codex.wordpress.org/Category_Templates

  6. Matthew Meyer
    Member
    Posted 2 years ago #

    Thank you.

    I'm still having a bit of trouble doing what I want to do.
    Here's what I'm aiming for:

    I want to make separate menu items on the main menu that will only display posts from different categories. For example, "Chinese Blog" and "Portuguese Blog." If you click on the Chinese Blog, it will show you only those posts in that category; and similarly if you click on Portuguese Blog it will only show you those posts in that category.

    My thought was to use Pages using that "A Page of Posts" template above, but as I said I couldn't figure out how to change the php code from reading the Category Name field to the Category ID field (my category names changes in different languages due to the multilingual plugin I am using, so that field is not useful for me).

    Using category templates would work just fine as well, but how can I turn them into Pages so they appear on the site's Menu?

  7. Matthew Meyer
    Member
    Posted 2 years ago #

    Alright well, I found one way to workaround this since nobody can help me with the template. In case anyone finds this post later on and wonders how I did it, all I had to do was put the url for the category I wanted as the page title. In other words, for the page title, I wrote

    < a href="index.php?cat=4">Portuguese Blog< /a>

    (without the spaces)

    and that did the trick.

Topic Closed

This topic has been closed to new replies.

About this Topic