{"id":3676,"date":"2018-05-05T16:19:00","date_gmt":"2018-05-05T16:19:00","guid":{"rendered":"https:\/\/purelysupp.com\/wordpress\/?p=3676"},"modified":"2022-10-17T22:32:52","modified_gmt":"2022-10-17T22:32:52","slug":"custom-shop-post-type-to-genesis-child-theme-for-your-online-store","status":"publish","type":"post","link":"https:\/\/purelysupp.com\/wordpress\/code-snippets\/custom-shop-post-type-to-genesis-child-theme-for-your-online-store\/","title":{"rendered":"Custom Shop Post Type to Genesis Child-Theme for Your Online Store"},"content":{"rendered":"\n<p>Add the following code to your WordPress theme&#8217;s function.php file, or a functionality plugin to create a custom Shop Post Type For Your Online Store. <\/p>\n\n\n\n<p>* Note &#8211; If you are using a Shop plugin like WooCommerce, this wouldn&#8217;t be necessary. The use scenario for this code is if you have an external shop like <a href=\"\/\/www.kickstartcart.com\/app\/?pr=31&amp;id=26147\" target=\"_blank\" rel=\"noreferrer noopener\">1Shopping Cart<\/a> or use PayPal Links.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/** Custom Shop Post Types *\/\n\nfunction be_shop_template( $template ) {\n  if( is_tax( array( 'shop_category', 'shop_tag' ) ) )\n    $template = get_query_template( 'archive-shop' );\n  return $template;\n}\nadd_filter( 'template_include', 'be_shop_template' );\n\n\/** Add 'page-attributes' to shop Post Type\n * @param array $args, arguments passed to register_post_type\n * @return array $args  *\/\n\nfunction be_shop_post_type_args( $args ) {\n\t$args&#91;'supports']&#91;] = 'page-attributes';\n\treturn $args;\n}\nadd_filter( 'shopposttype_args', 'be_shop_post_type_args' );\n\n\/** Sort projects by menu order \n *\n *\/\nfunction be_shop_query( $query ) {\n\tif( $query->is_main_query() &amp;&amp; !is_admin() &amp;&amp; ( is_post_type_archive( 'shop' ) || is_tax( array( 'shop_category', 'shop_tag' ) ) ) ) {\n                $query->set( 'posts_per_page', '25' );\n\t\t$query->set( 'orderby', 'menu_order' );\n\t\t$query->set( 'order', 'ASC' );\n\t}\n}\nadd_action( 'pre_get_posts', 'be_shop_query' );\n\n\/** remove_action( 'genesis_after_post', 'genesis_get_comments_template' ); *\/\n\nadd_action('get_header','cd_change_genesis_sidebar');\nfunction cd_change_genesis_sidebar() {\n    if ( is_singular('shop') || is_page( array( 1, 2, 3, 4 )) || is_post_type_archive('shop') ) { \n        remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );\n        add_action( 'genesis_sidebar', 'cd_do_sidebar' );\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>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.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Function to output my custom sidebar\r\nfunction cd_do_sidebar() {\r\n\tdynamic_sidebar( 'shop-single-sidebar' );\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Add the following code to your WordPress theme&#8217;s function.php file, or a functionality plugin to create a custom Shop Post Type For Your Online Store. * Note &#8211; If you are using a Shop plugin like WooCommerce, this wouldn&#8217;t be necessary. The use scenario for this code is if you have an external shop like\u2026&nbsp;<a href=\"https:\/\/purelysupp.com\/wordpress\/code-snippets\/custom-shop-post-type-to-genesis-child-theme-for-your-online-store\/\" class=\"rmlink\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":3547,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","iawp_total_views":3,"wds_primary_category":56,"footnotes":""},"categories":[56,69],"tags":[195,161],"class_list":{"0":"post-3676","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-code-snippets","8":"category-user-experience","9":"tag-custom-post-type","10":"tag-ecommerce","11":"entry"},"featured_image_src":"https:\/\/purelysupp.com\/wordpress\/wp-content\/uploads\/sites\/2\/2018\/09\/code-snippits-600x400.jpg","featured_image_src_square":"https:\/\/purelysupp.com\/wordpress\/wp-content\/uploads\/sites\/2\/2018\/09\/code-snippits-600x515.jpg","author_info":{"display_name":"Jack Alltrade","author_link":"https:\/\/purelysupp.com\/wordpress\/author\/jacka11trade\/"},"_links":{"self":[{"href":"https:\/\/purelysupp.com\/wordpress\/wp-json\/wp\/v2\/posts\/3676","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/purelysupp.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/purelysupp.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/purelysupp.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/purelysupp.com\/wordpress\/wp-json\/wp\/v2\/comments?post=3676"}],"version-history":[{"count":3,"href":"https:\/\/purelysupp.com\/wordpress\/wp-json\/wp\/v2\/posts\/3676\/revisions"}],"predecessor-version":[{"id":10770,"href":"https:\/\/purelysupp.com\/wordpress\/wp-json\/wp\/v2\/posts\/3676\/revisions\/10770"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/purelysupp.com\/wordpress\/wp-json\/wp\/v2\/media\/3547"}],"wp:attachment":[{"href":"https:\/\/purelysupp.com\/wordpress\/wp-json\/wp\/v2\/media?parent=3676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/purelysupp.com\/wordpress\/wp-json\/wp\/v2\/categories?post=3676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/purelysupp.com\/wordpress\/wp-json\/wp\/v2\/tags?post=3676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}