1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Is it possible to do this in the WordPress?

Discussion in 'Blogging' started by aspe_heat, May 12, 2013.

  1. aspe_heat

    aspe_heat Power Member

    Joined:
    Oct 7, 2010
    Messages:
    799
    Likes Received:
    595
    Gender:
    Male
    Probably only a WordPress expert can help me with this, so hopefully I'll find one here!

    I created "main" categories, six of them. Each category has 5 sub-categories. However, I only use sub-categories and never categories. So when I go to www.mysite.com/main-category it opens all the posts written under sub-categories. What I am wondering is following : is it possible to make that link point to a WordPress page or a post? So when I go to it, I would be redirected to a page/post instead of getting list of all the posts under sub-categories.

    I tried creating a page and setting its permalink to main-category, but it didn't work.

    Thanks for the help!
     
  2. WeEDreeM_

    WeEDreeM_ Newbie

    Joined:
    Apr 1, 2013
    Messages:
    29
    Likes Received:
    11
    Occupation:
    TREE INDUSTRY
    Location:
    WhiteState
    Home Page:
    You try, Redirection plugin ?
     
    • Thanks Thanks x 1
  3. makemecash

    makemecash Regular Member

    Joined:
    Mar 16, 2012
    Messages:
    279
    Likes Received:
    303
    You wouldn't actually create a new page, you would create a new category page file.

    Normally when you create a custom page it would be like "page-aboutus.php", but in this case you would use the category. So it would be like "category-aboutus.php"

    You can read more about the category hierarchy here: http://codex.wordpress.org/Category_Templates

    If you aren't able to code up a new page, just copy the contents of page.php into new category page file. Or if you want to get the contents of that category on your custom category page, you could include this above your loop:

    Using category ID
    <?php query_posts("cat=203"); ?>

    Using category name
    <?php query_posts("category_name=aboutus"); ?>

    You can read more about that here: http://codex.wordpress.org/Function_Reference/query_posts
     
    • Thanks Thanks x 1
  4. aspe_heat

    aspe_heat Power Member

    Joined:
    Oct 7, 2010
    Messages:
    799
    Likes Received:
    595
    Gender:
    Male
    The plugin works like a charm, thanks a lot!

    Thanks to you also, makemecash, for the useful information you posted! I'll make sure I read it all so I can learn more.
     
  5. makemecash

    makemecash Regular Member

    Joined:
    Mar 16, 2012
    Messages:
    279
    Likes Received:
    303
    Be aware that with the redirection plugin you are doing a 301 redirect. It would be better for you to skip the redirect and have a straight page.

    However, if you must do a redirect then use the code below. Since WP is database heavy, the more plugins you use the more server resources you use and your page load time increases.

    Simply create a custom category file "category-yourpagesname.php"
    Then inside the file just include the following code:

    <?php header( 'Location: http://www.yoursite.com/new_page' ) ; ?>
     
    • Thanks Thanks x 1
  6. aspe_heat

    aspe_heat Power Member

    Joined:
    Oct 7, 2010
    Messages:
    799
    Likes Received:
    595
    Gender:
    Male
    Alright, thanks again!
    Just one more question - why is it bad to have 301 redirect?
     
  7. aspe_heat

    aspe_heat Power Member

    Joined:
    Oct 7, 2010
    Messages:
    799
    Likes Received:
    595
    Gender:
    Male
    I've just found the way to do it without the plugin...I am just not sure if it's considered a 301 redirect again?

    If my category page link is mysite.com/category-page, I would create a new page with the name "Category Page" so it would automatically create mysite.com/category-page permalink. Then I would have two different pages with the same link. However, I would then edit that page and change the permalink to mysite.com/category-page-real or something like that, and whenever someone would go on the category, she/he will land on the page I created.