how can i create archives for custom post type - wordpress

the WordPress framework allows to build different archive templates for each of your custom post type by e.g:
archive-event.php
taxonomy-event_category.php
is it possible to create author and date archive for custom post type by doing the following:
author-event.php
date-event.php
if this is not possible, can anyone advise how i can go about achieving this?

I think these links will help answer your question and get you started:
http://codex.wordpress.org/Template_Hierarchy
http://codex.wordpress.org/Category_Templates
The gist of it is that you can in fact make an author-event.php however date-event.php does not get checked because the template hierarchy dictates that it uses date.php, archive.php, or index.php.
One solution is to use conditional tags such as is_author() or is_date(). If you do, keep in mind that you'll have to have a common archive.php and decide which template you really want to use by using conditional tags.

Related

Archive-style page for a custom taxonomy

I've been trying with no luck to use built-in template hierarchy to get a simple page that would list all terms for a custom taxonomy.
I have a custom taxonomy "editions" (linked to a custom post type "courses").
I have my template that I named "taxonomy-editions.php" (also tried archive-editions.php) which is called when I try to access a given edition (/editions/2016 for example, and archive-editions.php does the same btw). But whenever I try to access /editions/, no template is called (apart from index.php).
Am I doing something wrong here, or is it simply not possible to do that without creating a custom page ? (most of the answers I've found are 2 years old or more).
Thank you in advance
If you are using the custom taxonomy , then please use the following templates for custom taxonomy and just copy the archive code over this template.
taxonomy-{taxonomy}-{term}.php
taxonomy-{taxonomy}.php
tag-{slug}.php
tag-{id}.php
category-{slug}.php
category-{ID}.php
Also don't forget to use this variables as true when you registering the taxonomy,
publicly_queryable=>true
hierarchical=>true
You can check the usage of register_taxonomy here.

WordPress: Same Permalink structure for pages, a custom post type and a taxonomy?

Is it possible to have the same permalink structure for pages, a custom post type and a custom taxonomy. The desired permalink for them all is http://sitename.com/{slug}
How can I achieve that?
You can use plugin custom permalink. By using this plugin you can set url as u want.
http://wordpress.org/plugins/custom-permalinks/
Short answer: Yes and No. You can code something up yourself, create some fancy .htaccess rules or use a combination of plugins.
See this post, despite its name, someone does suggest a plugin - I've used the plugin they talk about (wp-no-category-base), it does the job. Be aware that you could be asking for trouble doing this (for instance if you try to label a particular post with the same name as the category/custom taxonomy/etc - read the accepted answer here: https://wordpress.stackexchange.com/questions/42120/remove-slug-in-taxonomy-url):
Remove category & tag base from WordPress url - without a plugin
I'm fairly sure it handles custom post types - can't remember. If not, check out this:
https://github.com/markoheijnen/wp-no-taxonomy-base
Note: this code has not been updated in a long time.

Creating a custom permalink structure based on post fields

I am wondering if it is possible to create a bespoke permalink structure which is based off some of the custom fields I have in my post.
The custom post fields are: film_director, film_name (these will be consitent through out the website)
So the structure I would like to create is as follows:
http://domain.com/%film_director%/%film_name%/%postname%
I'm not great with Wordpress specific terminology so I might just be looking with the wrong keywords however is this something that can be completed (with use of either a plugin or custom code)
Thanks :)
Yep you can do this : here is a nice tutorial about it : http://firecask.com/custom-fields-and-posts-in-wordpress-permalink-urls/
I also find a plugin which seems to do this, but it's quite an old one. http://wordpress.org/plugins/custom-fields-permalink/

Wordpress: Comment on Archive Pages

I'm currently developing a Wordpress site/theme for a client.
He has a specific requirement to be able to add comments to an archive page - it actually needs to be a comment on the page itself, rather than the posts/products within that archive.
I effectively need a way to add comments.php to the bottom of archive.php, although I understand this won't work because an archive page doesn't have an ID for the comments to associate with.
Is there any way to give a category archive page an ID based on the category, and then hook the comments template into this ID for each archive?
Thanks so much in advance for any advice you can offer - it's been a long process and this is the last bit remaining to finalise the project!
Unfortunately it would seem this isn't directly possible, however for anyone who would like to do something similar, there is a third party comment solution called IntenseDebate which is suitable to be added to the archive pages.
If you use DISQUS, you can call the comments template using PHP to bypass WordPress checks and have comments on archives pages.
include 'comments.php';

Wordpress, alternative single post template

For a project of mine I need to define an alternative template for single posts.
To be more specific I need each post to be displayed as usual when the website is browsed but I need to create different single pages reachable from different URL to create a sort of a mini-website for each post.
(I'm actually using the WooCommerce plugin and what I need to do is to create a mini-website for each product. This needs to be something "outside" from the main website, with a complete different graphic template and is going to be reachable through a QR-code).
Hope it makes a bit of sense.
Thanks for your advices and/or suggestions.
Angelo
I think the easiest way to do that is by registering a custom post type for the special posts that get this special "single.php" template. Then, you can simply write a new single template titled post-[custom post_type].php. Any post you register of this type will use that template.
OR...
If you don't actually need them to be posts, it's even easier if you publish them as pages. By default, pages let you assign a specific page template in the edit screen. So you could make any number of custom templates. Just make sure you add the special header:
/* Template Name: Custom Page */
...so WP knows it's a page template.

Resources