Grow your CSS skills. Land your dream job.

strange wordpress category problem

  • # January 19, 2011 at 5:35 pm

    Hi!
    I made an a category that i call “news”
    I put fancy permalinks /%postname%
    I also made a menu and put “news” in it.

    But when i navigate to this category “news” the url is like this: localhost/category/news
    What i want is to be just: localhost/news

    Any sugestion?
    Thanks for help

    # January 19, 2011 at 5:56 pm

    when you say “put fancy permalinks” do you mean you went to “Settings->permalinks” and changed the setting to custom and entered /%postname%/ or did you use a plugin?

    # January 19, 2011 at 5:57 pm

    also, visiting /news/ would lead you to the PAGE called /news/ . If you want to have it just be localhost/news/ just create a page called news, then use a page template for that page and query for all posts in the category news.

    # January 20, 2011 at 4:01 pm

    Thanks for helping out.

    I went to settings-permalinks etc. yes
    I’ll try what you suggest. I don’t know what you mean by use a page template. Will google…
    Thanks

    # January 21, 2011 at 12:56 pm

    This is a text copy from:
    http://www.wprecipes.com/how-to-remove-category-from-your-wordpress-url


    By default, WordPress category permalinks are displayed that way:

    http://www.catswhocode.com/blog/category/wordpress

    As you can see, the category in the url is pretty useless. Here’s how to remove it:

    First backup your .htaccess file. Then, open it and append the following line:

    RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L]

    Once saved, your categories pages will be displayed like this:

    http://www.catswhocode.com/blog/wordpress

    WIll i be making more trouble in future with this, or is it safe?

    # January 21, 2011 at 1:45 pm

    If you have a page called wordpress and a category called wordpress, then yes, you will be making a headache for yourself. Honestly the /category/ in the link really helps me know that im browsing all posts in that category.

    # January 21, 2011 at 1:46 pm

    What is your end goal? Is it to make a page called “news” and display all of the posts with the news category attached to them?

    # January 21, 2011 at 2:31 pm

    My end goal is to have like you said: Page called news and all the posts from news category attached to them.
    The problem is that this will be a redesign of an old static page that has a url for example: mydomain.com/news and if i put different url
    ( /category/ in between) it will broke many links from other sites.

    One thing that partly solves my problem is to set a static page and to choose a post page: “news”. That seems to work

    # January 21, 2011 at 5:55 pm

    you could try querying for the news category on your news page.

    Make a blank news.php page in your theme file and use this code to make it a template


    < ?
    /*
    Template Name: News
    */

    get_header();

    then to query for posts in the news category, just use the query_posts function


    //The Query
    query_posts( 'category_name=news' );

    //The Loop
    if ( have_posts() ) : while ( have_posts() ) : the_post();
    //put all of your code in here to echo a post, such as:
    the_title();
    endwhile; else:

    endif;

    //Reset Query
    wp_reset_query();

    //this calls the sidebar, if you dont want that, then delete this next link
    get_sidebar();
    //this next line calls the footer.
    get_footer();
    ?>

    So all together your code in news.php looks like this.


    < ?
    /*
    Template Name: News
    */

    get_header();

    //The Query
    query_posts( 'category_name=news' );

    //The Loop
    if ( have_posts() ) : while ( have_posts() ) : the_post();
    //put all of your code in here to echo a post, such as:
    the_title();
    endwhile; else:

    endif;

    //Reset Query
    wp_reset_query();

    //this calls the sidebar, if you dont want that, then delete this next link
    get_sidebar();
    //this next line calls the footer.
    get_footer();
    ?>

    then go into your backend to the news page and choose “news” from your template dropdown on the right-hand side.

    Hope this helps you get where you need to go.

    # January 29, 2011 at 1:33 pm

    Thanks dhechler for this. Friend that im setting up this, decided its not a big deal to have a /something/ in between, but ill sure use your sugestion sometime in the future.

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".