I have two categories of posts on my site, for which I'd like to use the archives.php page.
I've already used it for REFERENCES.
I want to now use it for posts with a category of NEWS, but the customisations I've done for REFERENCES don't really work. Is there a way I can break to one archive page into two, or have a second archives.php page?
The Codex is very useful. That said:
http://codex.wordpress.org/Category_Templates
In the case of categories, the hierarchy is fairly simple. For instance, suppose the slug of the Category in question is news and the Category ID is 6. The Template Hierarchy specifies that WordPress will use the first Template file it finds in your current Theme's directory from the following list:
category-slug.php (Note: available with Version 2.9)
category-ID.php
category.php
archive.php
index.php
That is, if you do not have a category-slug.php (lets say category-news.php), WordPress will check for a category-ID.php (like category-6.php), and so on.
Related
here is an example i have set the category as fruit->red->apple and i want to set custom pages for apple.
I tried adding file in my child theme copping the codes from category.php and making the new file as apple.php and made some modifications to it but it didn't worked out
If you're are using the default wordpress post category, then this is what you're looking for: category-apple.php you just have to duplicate your category.php file and customize it has you want.
If you're are using a custom taxonomy, then this is what you're looking for: taxonomy-fruit-apple.php you just have to duplicate your taxonomy.php file and customize it has you want.
These files let you target specific taxonomies or specific taxonomy terms. For example:
taxonomy-{taxonomy}-{term}.php
taxonomy-{taxonomy}.php
tag-{slug}.php
tag-{id}.php
category-{slug}.php
category-{ID}.php
You can learn more about the taxonomy.php file # https://developer.wordpress.org/themes/template-files-section/taxonomy-templates/
You can get a better understanding of how the wordpress template hierarchy works # https://developer.wordpress.org/themes/basics/template-hierarchy/
vEdit 1.1
I have woocommerce plugin. I created a custom tag taxonomy under products to pick the product ingredients. ( https://pasteboard.co/J2BlgqI.png ). To show them as buttons on the product page ( https://pasteboard.co/J2Bn7FD.jpg ).
Now I want the visitor when they click on the ingredient it shows them an ingredient page information. So, if they click on “Beeswax” it shows them Beeswax information like name, function and etc…
Each time I click on “Beeswax it directs me to a filter page https://pasteboard.co/J31hg2w.png .
How can I make a page for each ingredient?
Is it even doable this way? or is there another way to accomplish this?
please advice…
thanks
Yes you can have custom templates for your taxonomies. The template hierarchy explains everything.
Custom taxonomies use this template file path:
taxonomy-{taxonomy}-{term}.php – If the taxonomy is sometax, and taxonomy’s term is someterm, WordPress will look for
taxonomy-sometax-someterm.php. In the case of post formats, the
taxonomy is ‘post_format’ and the terms are ‘post-format-{format}.
i.e. taxonomy-post_format-post-format-link.php for the link post
format.
taxonomy-{taxonomy}.php – If the taxonomy were sometax, WordPress would look for taxonomy-sometax.php.
taxonomy.php
archive.php
index.php
Since you haven't created a taxonomy-ingredients.php WordPress uses the next available option and falls back to the generic template.
You can even create a different template (page) for each of your Ingredient by using the first option above.
Hiall,
In my wordpress site I have a Category called “meetings”, and it’s slug is “meeting”, also its ID is 27.
I create a default post article and then select “Meeting” from the categories panel and then publish etc.
Reading here
http://codex.wordpress.org/Template_Hierarchy#Custom_Taxonomies_display
If I create a template file called category-meetings.php or category-27.php then it should pick those files up and use them for a template layout for my selected Meeting category posts etc???
But for whatever reason I can not get it to do this.
I have also tried changing the permalinks settings from “post name” to custom structre with /%category%/%postname%/
but again no luck.
Am I missing something here?
Any help would be great!
I think you're trying to target a single post, whereas your template is targeting the category archive pages. For example, look at this diagram of the template hierarchy.
You could:
1) Create that post as a page and then create a template just for that page.
2) Create a custom post type and create a custom template for that custom post type.
The naming has to match your slug. I would change
category-meetings.php
to
category-meeting.php
And make sure the category-customname.php files are in the same directory as the default category.php file.
Addition/Revision
For a custom page for a single post -- find the post number, let's say 999, then create a single page with the past number appended to the file name in the same directory where the single.php file exists. This worked up to WP ver 3.2-ish. Unless it's been deprecated, it should still work.
single-999.php
I wanted to create a new page similar to author.php in wordpress, but that lists only a specific Custom Post Type. It is important to have both pages: author.php for regular posts, and this new author-custom-post.php only for the Custom Post Type.
The usage is that the first one will list the blog posts, and the other one will list the author's cientific publications, each one in its own page.
And, of course, it should have a link to this author-custom-post.php that I can use in the author bio.
I could only manage to find pages listing both things together, but nothing about listing in different pages.
Thanks in advance!
I have two categories that need a special template. Each has one post and will display differently. So I read that if the category is named, for example, 'testing' and the template name is 'testing.php' then it should use that correct?
Why would it not? I keep previewing the post and it just redirects to the home page.
Naming the template testing.php won't work. You need to use either a slug or ID of your category, so either category-testing.php or category-ID.php if you know the ID of category (ie. you're not making a theme for release and your IDs are constant).
Category templates, which your version of WordPress has, can do it.
What version of WordPress are you running. WordPress 3.0 is new and will support what you want out of the box as you described.