Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other strange wordpress category problem

  • This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #31311
    supperman
    Participant

    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

    #65165
    dhechler
    Member

    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?

    #65156
    dhechler
    Member

    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.

    #65103
    supperman
    Participant

    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

    #64860
    supperman
    Participant

    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?

    #64846
    dhechler
    Member

    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.

    #64835
    dhechler
    Member

    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?

    #64772
    supperman
    Participant

    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

    #64659
    dhechler
    Member

    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.

    #63453
    supperman
    Participant

    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)
  • The forum ‘Other’ is closed to new topics and replies.