• Skip to main content
  • Skip to primary sidebar
  • Business
  • WordPress
  • Security
  • Marketing
  • Publicity
  • Computing
  • Resources
  • Whatevs

Purely Wordpress

Just The Tech, News, and Info We Deem To Post

  • Home
  • About
  • Contact
  • Contribute
You are here: Home / Code Snippets / Custom Shop Post Type to Genesis Child-Theme for Your Online Store

Custom Shop Post Type to Genesis Child-Theme for Your Online Store

Screenshot of WordPress plugin php and html code

Add the following code to your WordPress theme’s function.php file, or a functionality plugin to create a custom Shop Post Type For Your Online Store.

* Note – If you are using a Shop plugin like WooCommerce, this wouldn’t be necessary. The use scenario for this code is if you have an external shop like 1Shopping Cart or use PayPal Links.

/** Custom Shop Post Types */

function be_shop_template( $template ) {
  if( is_tax( array( 'shop_category', 'shop_tag' ) ) )
    $template = get_query_template( 'archive-shop' );
  return $template;
}
add_filter( 'template_include', 'be_shop_template' );

/** Add 'page-attributes' to shop Post Type
 * @param array $args, arguments passed to register_post_type
 * @return array $args  */

function be_shop_post_type_args( $args ) {
	$args['supports'][] = 'page-attributes';
	return $args;
}
add_filter( 'shopposttype_args', 'be_shop_post_type_args' );

/** Sort projects by menu order 
 *
 */
function be_shop_query( $query ) {
	if( $query->is_main_query() && !is_admin() && ( is_post_type_archive( 'shop' ) || is_tax( array( 'shop_category', 'shop_tag' ) ) ) ) {
                $query->set( 'posts_per_page', '25' );
		$query->set( 'orderby', 'menu_order' );
		$query->set( 'order', 'ASC' );
	}
}
add_action( 'pre_get_posts', 'be_shop_query' );

/** remove_action( 'genesis_after_post', 'genesis_get_comments_template' ); */

add_action('get_header','cd_change_genesis_sidebar');
function cd_change_genesis_sidebar() {
    if ( is_singular('shop') || is_page( array( 1, 2, 3, 4 )) || is_post_type_archive('shop') ) { 
        remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
        add_action( 'genesis_sidebar', 'cd_do_sidebar' );
    }
}

is_page( array( 1, 2, 3, 4 )) where 1, 2, 3, and 4 are the IDs of the pages that should use the custom post type.

//Function to output my custom sidebar
function cd_do_sidebar() {
	dynamic_sidebar( 'shop-single-sidebar' );
}

by Jack Alltrade on May 5, 2018

Filed Under: Code Snippets, User Experience Tagged With: Custom Post Type, eCommerce

Reader Interactions

Share Your Two Cents Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Categories

  • Code Snippets
  • Development
  • File Management
  • Genesis Framework
  • Hosting
  • Legacy
  • Plugins
  • SEO
  • Tech Terms
  • Themes
  • User Experience
  • User Interface
  • WordPress Core
  • WordPress Functionality

Warning! Use at your own risk!

As always, use at your own risk and remember to backup your site prior to inserting new code.

© Copyright Jack Alltrade & Associates 2025 · Purely Supplemental™ is a trademark of Jack Alltrade & Associates