Community Forums › Forums › Archived Forums › Design Tips and Tricks › Change Default Blog output Custom Taxonomy
- This topic has 1 reply, 1 voice, and was last updated 10 years, 7 months ago by pxforti.
-
AuthorPosts
-
January 26, 2014 at 12:42 pm #87111pxfortiParticipant
Hi,
Using genesis 2.0.2 /
I created a custom post type for recipes. I also created a custom taxonomy for recipe categories. I also created a custom archive page called archive-recipes.php which displays at http://dev.winedinedaily.com/recipes. All this works.When I click on main recipes link, it displays my custom archive-recipes.php layout. But when I click on an individual category, it displays the default genesis blog archive layout.
What I want is to use the formatting from archive-recipe.php for all recipe categories.
Any idea how to make the default category / archive display use my archive-recipes.php? I appreciate any clues you can give me for how to get started on this.
Below is the code I used to create my custom post type, custom taxonomy, and custom archive page.
custom post type and custom taxonomy code/* Create portfolio custom post type ------------------------------------------------------------ */ add_action( 'init', 'recipe_post_type' ); function recipe_post_type() { register_post_type( 'recipes', array( 'labels' => array( 'name' => __( 'Recipes' ), 'singular_name' => __( 'Recipe' ), ), 'exclude_from_search' => false, 'has_archive' => true, 'hierarchical' => false, 'taxonomies' => array('recipe_categories', 'post_tag' ), 'menu_icon' => get_stylesheet_directory_uri() . '/images/portfolio.png', 'public' => true, 'rewrite' => array( 'slug' => 'recipes' ), 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'genesis-seo', 'genesis-cpt-archives-settings' ), ) ); } /* add recipe category ------------------------------------------------------------ */ add_action( 'init', 'recipe_taxonomy', 0 ); function recipe_taxonomy() { $labels = array( 'name' => _x( 'Recipe Categories', 'taxonomy general name' ), 'singular_name' => _x( 'Recipe Category', 'taxonomy singular name' ), 'search_items' => __( 'Search Categories' ), 'all_items' => __( 'All Categories' ), 'parent_item' => __( 'Parent Category' ), 'parent_item_colon' => __( 'Parent Category:' ), 'edit_item' => __( 'Edit Category' ), 'update_item' => __( 'Update Category' ), 'add_new_item' => __( 'Add New Category' ), 'new_item_name' => __( 'New Category Name' ), 'menu_name' => __( 'Recipe Categories' ), ); register_taxonomy('recipe_categories',array('recipes'), array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'recipe-categories' ), )); }
archive-recipes.php code
<?php /** * The custom portfolio post type archive template originally by Brian Gardner at http://www.briangardner.com * Modified by yo for Genesis 2.0 */ /** Force sidebar-content layout */ add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_sidebar_content' ); function wine_top_widget() { genesis_widget_area( 'recipe-top', array( 'before' => '<div class="recipe-top widget-area">', 'after' => '</div>', ) ); } add_action( 'genesis_loop', 'wine_top_widget', 1 ); /** Remove the post info function */ remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); add_action( 'genesis_entry_footer', 'genesis_do_post_title' ); remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); /** Remove the post content */ remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); /** Remove the post image */ remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); /** Add the featured image after post title */ add_action( 'genesis_entry_header', 'minimum_portfolio_grid' ); function minimum_portfolio_grid() { if ( has_post_thumbnail() ){ echo '<div class="portfolio-featured-image">'; echo '<a href="' . get_permalink() .'" title="' . the_title_attribute( 'echo=0' ) . '">'; echo get_the_post_thumbnail($thumbnail->ID, 'recipes' ); echo '</a>'; echo '</div>'; } } /** Remove the post meta function */ remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); genesis();
writeNowDesign
WordPress and Ecommerce Website DesignJanuary 27, 2014 at 11:47 am #87248pxfortiParticipantI finally figured this one out. the archive-recipe.php file works only for a single url; eg, /recipes.
Because I added custom taxonomy for hierarchical categories, I need a page called taxonomy-recipe-categories.php (recipe-categories is the taxonomy I registered.
writeNowDesign
WordPress and Ecommerce Website Design -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.