Taxonomy Archive Pages

resolved (20 posts) (4 voices)

  1. KenScott
    Member

    Hi
    I have created a Custom Post Type with a simple taxonomy, and I am displaying posts on a blog_list page. The blog shortcode has been amended to allow me to specify the post_type.

    I have also created a custom menu for the taxonomy (like a category menu), and want to display an Archive page or Category page when a link is clicked.However, I just get 404 errors when I do so.

    I've followed the suggestions in this thread http://mysitemyway.com/support/topic/infocus-archive-page#post-35660 and created a taxonomy-{taxonomy-name} template. What happens then is that the blog_list page displays one of my portfolio categories instead, strangely.

    Any ideas gratefully received. Thanks in anticipation.
    ... Ken

    Posted 2 years ago #
  2. Elliott
    Support

    Hello KenScott,

    You did this? http://mysitemyway.com/support/topic/infocus-archive-page#post-35693

    That will make it so all post types are queried including the portfolios.

    Posted 2 years ago #
  3. KenScott
    Member

    Hi Elliott
    Yes I did that, and you're right: the portfolio categories appeared too. But I only want the single Post_Type to display on that blog_list page, not other blog or portfolio categories. And then I want to create an Archive listing from a single taxonomy term when a user clicks its link in a Custom Menu widget.

    Posted 2 years ago #
  4. Elliott
    Support

    You'll want to remove that code then.

    Here are some related posts for using custom post types with our blog shortcode,

    http://mysitemyway.com/support/topic/shortcode-for-custom-posts#post-30033
    http://mysitemyway.com/support/topic/custom-posts-blog-shortcode#post-55693

    Posted 2 years ago #
  5. KenScott
    Member

    Thanks Elliott. I've used both of those (although I used the Types plugin to manage the Custom Post Type and Taxonomy). My blog shortcode was displaying a blog_list perfectly.

    However what I still need to do is a category sort / search on the terms in the taxonomy. Currently when I select a term, as I would a blog category) I get a "No Archives found" return. It is that which is causing me difficulty. So in summary the blog part works*, but the archive doesn't.

    *PS something has stopped working in the blog_list today in FF and Chrome (but OK in IE). The blog thumbnails are all displaying out of alignment in the list. You can see what I mean on the test site here: http://www.strataweb.co.uk/mc3/listings/

    Posted 2 years ago #
  6. KenScott
    Member

    I should have added that my shortcode looks like this
    [blog_list post_type="properties" thumb="medium" showposts="10"]

    Posted 2 years ago #
  7. Elliott
    Support

    Add [raw] [/raw] tags around your shortcode.

    Did you create a custom taxonomy for your properties post type? If so then you'll need to create a template for it, http://wp.smashingmagazine.com/2012/01/04/create-custom-taxonomies-wordpress/.

    Posted 2 years ago #
  8. KenScott
    Member

    Elliott you are a star; thank you. I hadn't come across [raw] tags before, but it sorted out my list.

    I did create a taxonomy, and a template. I will check the article you sent and persevere. Thanks again for the help.

    Posted 2 years ago #
  9. Carlo
    Member

    @kenScott

    It would seem that you have created a custom post type called "properties" and now you would create a list of "properties" posts using the blog shortcode.
    If that is what you do, read this Elliot's ansewre http://mysitemyway.com/support/topic/custom-posts-blog-shortcode .
    I have done like Elliot said, and in this way it doesn't need creating a custom template.

    @Elliot

    What is [raw] tag used for?

    Posted 2 years ago #
  10. Elliott
    Support

    Sometimes the content formatter will insert line breaks and paragraph tags if you nest the shortcodes / content in weird ways. Adding [raw] [/raw] around it will prevent that.

    Posted 2 years ago #
  11. KenScott
    Member

    @Carlo
    Thanks for your interest. Yes I am doing as you describe, but I changed the blog shortcode as Elliott describes in this thread http://mysitemyway.com/support/topic/blog-shortcode-to-query-custom-post-type-taxonomy#post-45416. It works as I intend it, but I haven't yet been successful in creating an archive page to display posts for terms in the taxonomy. I will post the answer when I get there.

    @Elliott
    re [raw] thanks again.

    Posted 2 years ago #
  12. Carlo
    Member

    Hello KenScott,

    In /awake/lib/functions/theme.php you would be able to see this code:

    if( is_archive() || is_search() ) {
    	$mysite->archive_search = true;
    	$args = array_merge( $wp_query->query, array( 'post_type'=> 'post', 'category__not_in' => mysite_exclude_category_string( $minus = false ) ) );
    	return query_posts( $args );

    In order creating an archive page to display posts for terms in the taxonomy, you would/should replace the code pasted above whit this:

    if( is_archive() || is_search() ) {
    		$mysite->archive_search = true;
    		if ( is_post_type_archive( 'your_post_type' ) || is_tax( 'your_taxonomy' ) )
    		$args = array_merge( $wp_query->query, array( 'post_type'=>'your_post_type' ) );
    		else
    		$args = array_merge( $wp_query->query, array( 'post_type'=>'post', 'category__not_in' => mysite_exclude_category_string( $minus = false ) ) );
    		return query_posts( $args );

    Where "your_post_type" is (for example) "properties" and "your_taxonomy" is an array with RELATED taxonomy terms.

    If you had more than one custom post type, you should add other IF conditions as many as your quantity's custom post type.

    Hope it helps!

    Posted 2 years ago #
  13. KenScott
    Member

    @Carlo
    Thanks so much for your interest and code. I will try it and advise the results.
    Thanks.
    ... Ken

    Posted 2 years ago #
  14. KenScott
    Member

    #UPDATE: @Carlo: thank for the code suggestion, which does enable an archive search on custom taxonomy terms, thank you.

    There is one more thing I want to do with this, however. In order to display search or archive results with a custom sidebar, as opposed to the generic blog sidebar, I guess I *will* need a custom template - taxonomy-{taxonomy-name}? How would I add a custom sidebar to this in Awake?

    Posted 2 years ago #
  15. Elliott
    Support

    If your using the latest versions of our themes you can set a custom sidebar for your archive pages in Dashboard -> your theme -> Specialty Pages.

    Posted 2 years ago #
  16. KenScott
    Member

    Yes I am using Awake 2.9. Thanks Elliott.Your support is brilliant and much appreciated.

    Posted 2 years ago #
  17. KenScott
    Member

    HI Elliott
    To complete this addition of archive pages for custom post types. I see how to add custom sidebars for Archive, Search and 404 pages in Dashboard -> Awake -> Specialty Pages.

    Trouble is that includes the custom post type specific sidebar in all archive pages. What I need is for the single page and the archive / search pages for the custom post to have a consistent custom sidebar structure separate from regular posts and archives.

    How can I accomplish this? I guess I still need template single-posttype.php, archive-posttype.php and taxonomy-posttype.php files?

    Posted 2 years ago #
  18. Elliott
    Support

    Open up /wp-content/themes/[your_theme]/lib/functions/theme.php and around line 500 you should see this,

    if( is_front_page() )
    	$sidebar = 'home';

    You can add something like this beneath that,

    if ( is_tax('your taxonomy') ) { $sidebar = "test"; }

    Where "test" is the name of your custom sidebar.

    Posted 2 years ago #
  19. KenScott
    Member

    Thanks Elliott
    That worked fine. I think it often a matter of finding where in the theme these things reside. For others benefit the code I used is:

    if ( is_tax('property_category') || is_tax('location') || is_tax('contract') )
    		$sidebar = "listings";
     
    	if ( is_singular( 'properties' ) )
    		$sidebar = "listings";

    In other words, use the same custom sidebar for all single posts of custom post type 'properties' and archives for the defined taxonomies.

    Excellent. Thank you.

    Posted 2 years ago #
  20. smudgedesign
    Member

    ahh great work im looking exactly for this too.
    cheers kenscott!

    Posted 2 years ago #

Reply

You must log in to post.

Construct WordPress Theme
Construct wordpress theme
Myriad WordPress Theme
Myriad wordpress theme
Method WordPress Theme
Method wordpress theme
Fusion WordPress Theme
Fusion wordpress theme
Elegance WordPress Theme
Elegance wordpress theme
Echelon WordPress Theme
Echelon wordpress theme
Dejavu WordPress Theme
Dejavu wordpress theme
Modular WordPress Theme
Modular wordpress theme