The MU forums have moved to WordPress.org

control which categorys posts are shown on frontpage (20 posts)

  1. Ovidiu
    Member
    Posted 17 years ago #

    hi there,

    basically what I want to achieve is having a way to exclude a certain category from the front-page.

    I tried these plugins: http://ryowebsite.com/?cat=11 (does not work and the new version for 2.1 needs mysql 4.1 so I cannot use that) and this one: http://smallestbusiness.com/category/wordpress (doesn't work either for me)

    I know there is another similar plugin from semiologic: http://www.semiologic.com/software/opt-in-front/ which works by creating a category that will be shown on the frontpage and initially moving all posts into that category, but I am not sure if this is what I need.

    any other hints how to exclude a certain category from the frontpage?

  2. Ovidiu
    Member
    Posted 17 years ago #

    Ok I think that I might have started this completely wrong, so I'll explain a little more in detail:

    I have a site that informs about recent/upcoming events. Obviously these should be categorized in different categories, such as: cultural events, clubs & pubs, cinema.

    The problem is that sometimes I have a lot of data for an event, so I want it to appear on the front page and sometimes I jsut have a title and a date for the event so I do not want to display these events on the front page.
    Additionally I want to display a list in the sidebar displaying the next 10 events from all events (categories) no matter if they appear or not on the front page.

    How I solved this until now was that I only had 2 categories: uncategorized and sideblog. All events were published into sideblog which made the mappear on the sidebar list, and those events I wanted displayed on the front page I put also in uncategorized - using the sideblog widget to display next 10 events in the sidebar with the sideefect, that the sideblog category is hidden from the front page.

    The problem arose only recently when I wanted to also put all events inside the coresponding category aka. cultural events, clubs & pubs, cinema which would automatically put them on the front page....

    One possible solution using the sideblog would be to make cultural events, clubs & pubs, cinema also sideblog categories, thus excluding them fro mthe front page and renaming uncategorized to frontpage so it is clear what that cetegory does.

    sorry for the long and winded post, I just wanted to make sure, I find and use the easieast way to do this... waiting for some suggestions.

  3. Ovidiu
    Member
    Posted 17 years ago #

    sorry for the bump, but had to do this. I need some ideas / input on this problem pretty much :-(
    I promise it will be my only bump on this thread.

    I really need a method to decide on a post-by-post base if that particular post gets shown on the frontpage or not.
    I imagined this would be easiest to achieve by including or not including a post in certain categories.

  4. drmike
    Member
    Posted 17 years ago #

    As to your original question - Would this just be for a single blog with a specific category or for a specific category sitewide?

    Post by post, I've got to think about.

  5. Ovidiu
    Member
    Posted 17 years ago #

    the problem is really only related to a single blog within the wpmu install.

    Like I said, a post from category cinema should show up on the front page if I have enough text for it, if not, it should not show up on the frontpage (just in the sideblog which I am using at the moment)

    Basically I would like two posts being in the same category treated differently => one frontpage the other one not.

    The only option to do this I came up with would be to assign them to different categories in addition to the common one they are already in.

  6. lunabyte
    Member
    Posted 17 years ago #

    Use home.php.

    Create an array of the category id's you wish to show.

    Inside the loop, check if the current posts category id is in the array of allowed id's or not. If not, continue on.

  7. drmike
    Member
    Posted 17 years ago #

    Hmm, didn't think of that. Either that or a special theme assigned to them with a specially created index.php. Better than my solution of having the core files and checking to see which blog is listing the posts.

  8. andrea_r
    Moderator
    Posted 17 years ago #

    You have to edit the theme's index file. Make or copy a theme and have it selected just for this blog.

    Edit the index file thusly:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
     <?php if ( !(in_category('25')) ) { ?>

    The first line is the first line of The Loop. The next line is one you have to ADD to the file to get it to exclude a particular category. make sure you've created that category as you need the ID number, in this case 25.

    Yes, I did this before and it worked, in a convoluted way to make one regular WP install looks like 2 blogs. :)

  9. Ovidiu
    Member
    Posted 17 years ago #

    still having problems, I'll give you an example:

    post a) is in categories: sideblog, music, frontpage

    => sideblog plugin shows all psots in sideblog category in sidebar and not on frontpage, music is there just to give the post a category, and frontpage tells wordpress to show it on frontpage

    post b) is in categories: sideblog, music

    => sideblog plugin shows all psots in sideblog category in sidebar and not on frontpage, music is there just to give the post a category

    ANY category except sideblog is shown on frontpage with my current index.php.

    I tried copying index.php to home.php and inserting

    <?php if (in_category('31')) : ?>
    31=frontpage as I thought that would only show posts from that category, but this lead to post a) showing twice as it is also in music.

    Sorry for bothering you but I can't come up with a decent solution for this.
    If I did not explain something understandable please ask.

  10. andrea_r
    Moderator
    Posted 17 years ago #

    Because it's in multiple categories is my bet. If you've got that bit of php in te Loop, and you put a post in catgory 31 - and nly that category - it will not show on the front page.

  11. Ovidiu
    Member
    Posted 17 years ago #

    @ andrea

    you are right the problem is indeed that the post is in 2 categories...

    back to the original problem:

    I need my posts categorized and a method to decide on a post by post basis if a posts shows up on the frontpage or not.

    THis was hust a first try, using categories, if there is another solution I am open for suggestions

  12. andrea_r
    Moderator
    Posted 17 years ago #

    Also, I think if something is in multiple categories, priority is given to the *first* category that it is in. Dunno if that helps or not.

  13. Ovidiu
    Member
    Posted 17 years ago #

    how is "first category" defined? by category ID?

  14. andrea_r
    Moderator
    Posted 17 years ago #

    I think so.

  15. suleiman
    Member
    Posted 17 years ago #

    Ovidiu, categories is definitely the way to go.

    I think I might have a solution for you old friend. Go to this url: http://www.fidgeting.net/ultimate-category-excluder/

    Download the plugin and upload to your /plugins/ folder. This will allow you to exclude categories which display on the frontpage, in your feeds, and in your archives.

    Hot stuff, am I right? ;)

  16. Ovidiu
    Member
    Posted 17 years ago #

    hello Suleiman,

    Indeed hot stuff but somethings wrong again. I installed and activated the plugin, then told it to exclude one category from the frontpage and my frontpage stopped displaying anything.

    btw. the category I excluded had only one post, all others should have still been on the frontpage...

    I am close to giving up :-(

    p.s. my index.php looks like this:

    <?php if (have_posts()) : ?>
    
            <?php while (have_posts()) : the_post(); ?>
    
                                    <?php the_date('d. F Y', '<h1 class="date">', '</h1>') ?>
     <div class="entry">
    
                                            <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
    
                                            <div class="entrycontent">
    ...
  17. Ovidiu
    Member
    Posted 17 years ago #

    found another plugin to help with this: http://www.gudlyf.com/archives/2005/03/08/wordpress-plugin-category-visibility/

    unfortunately setting it to not display a certain categories posts on the frontpage stops displaying anything on my frontpage.

    Coudl someone reread what I posted above about what I am trying to achieve? Does it make sense? Maybe I want something that does not work?

  18. lunabyte
    Member
    Posted 17 years ago #

    Is this for one particular site, or something for anyone who's registered?

    If it's for a single site, the home.php method would be the way to go, and then set up cat filtering like in the codex.

  19. Ovidiu
    Member
    Posted 17 years ago #

    ok, I have set up category filtering as it is only for one blog. I use the home.php but still have the problem, that posts assigned to multiple categories show up once for each category they are in...

    I do something like this: in the loop, first thing check if the post is inside the frontpage category, if not, move on to the next post, still posts that are in the frontpage category and in another category which is a fact for all of my posts, it shows up once for each category it is assigned to...

    have read the codex for several days now, still can't find anything useful..

  20. Ovidiu
    Member
    Posted 17 years ago #

    :-)

    I think I found the solution to my problem:

    http://wordpress.org/support/topic/101224?replies=8

    it seems the sideblog plugin was messing things up...

    anyone knows of another working asides plugin (preferably a widgetized one) ?

About this Topic