WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Need help to Display my categories (2 posts)

  1. mathew123
    Member
    Posted 5 years ago #

    Hi Guys,
    I need a help to Display my categories properly.
    for example, if i want to add Video, Music, News, Tech...categories to my theme, where do I have to modify code.

    Here is the instruction that template author provided, hoever I am not sure where do I have to sinsert new categories.

    please help:

    1. To show the category bar in the front page properly, you have to put the correct category IDs to this line in the index.php file:
    <?php $display_categories = array(5,6,7,8,11); $i = 1;
    foreach ($display_categories as $category) { ?>
    Notice that 5, 6, 7, 8, and 11 are the IDs of the category to be shown in the category bar.
    2. To show the post list in the front page properly, you have to put the correct excluded category IDs to this line in the index.php file:
    <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=-9,-15&paged=$page&posts_per_page=2"); ?>
    Notice that 9 and 15 are the IDs for the category: Headline and Featured. That will make no duplication shown in the front page. posts_per_page=2 means there are 2 posts listed per page. The navigation links are shown after the last listed post. You can change that to Lester-Chan’s WP-Pagenavi if you like.

  2. stvwlf
    Member
    Posted 5 years ago #

    You add their category id #'s in between the parentheses in this line of code, in the order in which you want them to display - a comma in between each except the last one

    array(5,6,7,8,11)

    To find the cat ID, go to the category maint screen - point at the name of the cat - look in the lower left corner at the browser's status line - you will see a URL - the cat ID is at the end of that URL.

Topic Closed

This topic has been closed to new replies.

About this Topic