• Resolved nemo-maritime

    (@nemo-maritime)


    I need help excluding some posts in certain categories from the frontpage/homepage of my WordPress site.

    I have tried using this code

    <?php
       if (is_home()) {
          query_posts("cat=-45, -119");
       }
    ?>

    in the index.php of my theme right above the
    <?php get_header(); ?>
    It did block out the categories from appearing from my main page, and it kept it accessible from the sidebar. HOWEVER, it gave me an issue with navigation of older posts on the site; the part where u look at older posts with the “older posts” link. The issue was that if I went to any other page of my site, it showed the same list of posts on any of the pages, or “older posts” link I clicked. Whole issue is documented here.

    So what I am looking for is help with excluding the categories with some other code, or someone explaining what could be causing the issue.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi

    This code fixes the issue of same posts being shown on all pages

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
          query_posts("cat=-45,-119&paged=$paged"); ?>

    Thread Starter nemo-maritime

    (@nemo-maritime)

    Yep! That did it. Thank you very much

    Thread Starter nemo-maritime

    (@nemo-maritime)

    Just notices a little part that came extra with the code. It now shows everything like it should, still, but on the fron page, after the title, it adds “Part 1”. How can I get rid of just that part? The url is perfect, its just the title bar itself shows, “Part 1” after the site title, and only for the post list. Same thing with page 2, it shows “Part 2” in the title

    Sounds like that is programmed into your theme. Is it the category/php template that is being used? If so, examine the code on it and see if the title is being modfied in the theme.

    I’m not familiar with this issue.

    Thread Starter nemo-maritime

    (@nemo-maritime)

    Hello,

    Not sure what is meant by “category/php template”, still learning : )

    I did look into the source code. I put the code you gave me into the index.php file, and I looked at where the title was comming from, and the code for the title, from the header.php, was:

    <title>
    <?php
    if (is_home()) { echo bloginfo('name'); }
    elseif (is_404()) { bloginfo('name'); echo ' - Oops, this is a 404 page'; }
    else if ( is_search() ) { bloginfo('name'); echo (' - Search Results');}
    else { bloginfo('name'); echo (' - '); wp_title(''); }
    ?>
    </title>

    Dont see a part about Part 1, or Part 2 and so on.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Exclude certain categories from the frontpage’ is closed to new replies.