- This topic is empty.
-
AuthorPosts
-
January 19, 2011 at 5:35 pm #31311
supperman
ParticipantHi!
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/newsAny sugestion?
Thanks for helpJanuary 19, 2011 at 5:56 pm #65165dhechler
Memberwhen 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 #65156dhechler
Memberalso, 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 #65103supperman
ParticipantThanks 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…
ThanksJanuary 21, 2011 at 12:56 pm #64860supperman
ParticipantThis 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 #64846dhechler
MemberIf 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 #64835dhechler
MemberWhat 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 #64772supperman
ParticipantMy 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 #64659dhechler
Memberyou 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 #63453supperman
ParticipantThanks 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.
-
AuthorPosts
- The forum ‘Other’ is closed to new topics and replies.