WordPress category link - wordpress

I am trying to create an online store from scratch, with categories and product pages.
Since is my first WordPress store I'm stuck on this trivial problem which stopped me on my way.
The permalinks are set to Month and name just to know the settings.
I created several categories where I want to insert the future products.
The problem arise when I try to access a certain category link - www.mysite.com/category/books/ - it displays the error page.
If I access www.mysite.com/category/ it shows me the content of the category page created in the admin panel.
All I want to do is to display all books when the visitor clicks on www.mysite.com/category/books/ and so on.

It is simple. Go to wp-admin/options-permalink.php and make your own settings: /%category%/%postname%/
And add a prefix on the field below: category or whatever you want
Read here for more options

Actually I solved it in another way, by modifying the category.php page.
There I inserted this code :
$uri = $_SERVER['REQUEST_URI'];
$elms = explode('/', $uri) ;
$catName = $elms[4] ;
and it does the thing I need.

Related

WP blog posts index URL

I want to use WP for a site that blog is just one aspect of it, and I don't want requests to home_url list blog posts (post_type=post), I want them be to fetched using another URL.
This topic default-archive-url-wordpress suggest two ways:
page_for_posts option
post_type=post URL query parameter
but I have questions
About the first, How a page would be able to loop into the posts, and where I should update this option (which hook)?
For the second, the guy says that using this param, make the wordpress get the archive for the specified post type, but I think posts don't have archive (according to includes/post.php their has_archive is left to default) how should I change this and also I want to use a permalink/pretty link for accessing posts.
Thanks in advance
Go to settings -> reading, and change the front page displays posts settings to front page displays a static page and then select a blog page.
Easy as pie.

How to create a costum template structure like for pages and post but for different entities like hotels, products etc

Hi everyone I am creating a wordpress theme and a custom plug-in which is related to hotel booking and display the information on the front end entered in the back end in admin panel of wordpress .
so friends whenever a post is displayed the url is like http://localhost/wordpress/uncategorized/post10/ and the name of the post or id of the post changes in a url but at the back end only single.php template get used by wordpress again and again so my question is can wee create something like that for different things for example in my case to display hotel only hotel.php file get used again and again and in url only the id of the hotel changes .
I didn't searched much about this on internet but I have seen something like that in wp-e-commerce plugin in which there is a separate template files to display the categories of products and also for products and those files are in the plugin directory.
You should first create custom post type (you will find plugins for that), for example a hotel post type.
Then you can easily create specific template for this post type, for example single-hotel.php.
More on codex :
http://codex.wordpress.org/Post_Types#Custom_Types
http://codex.wordpress.org/Post_Types#Template_Files

WordPress: Showing posts by categories/tags on the index page

Is it possible to show posts by categories/tags on the index page instead of taking the user to the tag.php and category.php pages?
For example, when the user clicks the 'Uncategorized' category, I would like all the Uncategorized posts to replace the list of posts already there on the index page.
I've been trying to find out if anyone has done this but I've had no luck. I'd really appreciate it if someone could give me a link to somewhere that tells me how to go about doing this or lets me know how to change the code to get this to work.
This can be done. I can not recall a page that has done it but I do know it would require you creating your own custom page template.
http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates is a good place to start learning how the page templates are created.
Some additional links
http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query
http://wordpress.org/support/topic/tag-archive-from-a-single-category-is-this-possible?replies=34

Display wordpress posts on different templates (not based via categories)

I am little more than beginner PHP programmer and just recently started to use wordpress. Right now I have big theoretical problem:
How to display in wordpress list of Posts (yes, default posts, not custom post type) with different template (does not have to be completely different new template) defined by current URL?
I am using Wordpress 3.3.2 and trying to customise wonderfull graphene theme. Runing on Linux/apache with mod_rewrite
Example:
I have posts in my page, which are displaying in front-page, and I have also created a menu with post categories. I am using permalinks.
www.mypage.com <- this shows list of all posts
www.mypage.com/category/dslr/ <- this shows list of all posts in selected category
www.mypage.com/2012/06/12/mozem-auto-komentovat/ <- this one shows single post
That is completely OK, easy to understand, no problem.
Example here: http://portal.vip.sk/vyvoj/astro/en where "astro" is root folder for this test instalation.
What I want to do:
Create a button in main menu, which will point to:
www.mypage.com/different-list
And on that link I will see all queried posts from DB, but the design and query will be different. Please note that different-list is not defined anywhere, nowhere even in the taxonomy, so when i try to use that link i get 404 error. I also want to use different custom fields from DB in this special listing.
The reason for this construction is as follows:
I want to let users publish their posts, categorise them, fill in metadata for these posts etc. BUT I also want to show these user posts in different manner under different URL. In this list, the posts will be grouped by months (or other time interval), by categories and will use one meta (boolean true, false). And of course the layout of the page will be completely different.
Thank you for any advice
To create a page template, create a new blank php file and populate it as follows:
<?php
/**
* Template Name: The name of you page template
*/
?>
<?php get_header(); ?>
Your content, queries, and stuff.
<?php get_footer(); ?>
Then add a new page, select as template "The name of you page template" and voila.
For custom fields I suggest you to use the "More Fields" wordpress plugin found here: http://wordpress.org/extend/plugins/more-fields/
Good luck! :)

Inserting a link to another post in Wordpress

I'm putting together a site based on a Wordpress template, and was wondering if there's a way to link one post to another without entering the full URL. I'd like to be able to use something that doesn't change if the parent directory or subdomain changes. Any ideas?
Posts
To link to a Post, find the ID of the target post on the Posts administration panel, and insert it in place of the '123' in this link:
Post Title
Categories
To link to a Category, find the ID of the target Category on the Categories administration panel, and insert it in place of the '7' in this link:
Category Title
Pages
To link to a Page, find the ID of the target Page on the Pages administration panel, and insert it in place of the '42' in this link:
Page title
(From Wordpress)
Linking Posts, Pages, and Categories
Something like: Post Title should work even if you use permalinks.
use below code to get particular post url and Title only by post id.
replace $postid with your post id that you want to display.
$postid = 1;
echo ''.get_the_title($postid).'';

Resources