redefining home() (6 posts)

  1. wsw70
    Posted 9 years ago #

    Greetings and happy new year 2006,

    I would like to somehow redefine "home()" -- the reason is that I would like the default page to be a category view.

    Namely, if you go to http://blog.swiatek.name (a useless blog with information nobody reads :)) you will see that there is a horizontal menu which is an ennumeration of the categories.
    What I would like to have is to directly jump into the "paplanie" category (first menu item) when accessing http://blog.swiatek.name
    (in other words so that http://blog.swiatek.name in fact opens http://blog.swiatek.name/?cat=1). I know how to do redirections in Apache but I would prefer to use a clean and native wordpress mechanism.

    I understand that this will effectively break my blog into a few blogs accessible via the horizontal manu and that I will not have a page listing all posts -- and this is exactly what I am looking for :)

    I would be grateful for a pointer (or solution).

    Thank you,

  2. Austin Matzko
    Posted 9 years ago #

    Try adding something like this to a file named functions.php in your theme's directory. It adds a rewrite rule that should do what you want. (functions.php needs to begin with <?php and end with ?>).

    function home_redirect($rules) {
    $newrules['$'] = 'index.php?cat=1';
    $rules = array_merge($newrules,$rules);
    return $rules;
    add_filter('rewrite_rules_array', 'home_redirect');

    It works for me.

  3. wsw70
    Posted 9 years ago #

    Thanks for the hint but it did not work.
    Now - I wonder whether the finctions.php file is read in at all. I have a similar problem with the style.css file -- if I update it the changes do not appear (for instance for my horizontal menu). If I add the CSS entries directly in header.php then it works.
    I use WordPress 2.0 -- the latter used to work in 1.5.

    Just a though -- I would appreciate someone more knowledgable to comment.

    Thank you,

  4. wsw70
    Posted 9 years ago #

    I decided to go for mod_rewrite in Apache to handle this and it works. I added lines like
    RewriteRule /paplanie /index.php/?cat=1
    in the definition of my virtual host (together with a RewiteEngine on).

    The question of style.css not being parsed is still there, though :)


  5. Austin Matzko
    Posted 9 years ago #

    Now - I wonder whether the finctions.php file is read in at all.

    It should be functions.php not finctions.php.

  6. wsw70
    Posted 9 years ago #

    Sorry for the delay - I had some issues with the blog and reverted back to pure standards :)

    The summary is that the trick above definitely does not work (sorry for the typo in the name - I was of course looking at functions.php).

    I really wonder whether this file is parsed at all as it was empty before I added the lines suggested by filosofo

Topic Closed

This topic has been closed to new replies.

About this Topic