Custom page for WooCommerce’s /product-category/

product-category URL uses taxonomy-product-cat.php which calls archive-product.php you will need to override it by creating the same file with the same name in themefolder/woocommerce/archive-product.php You can open any file in templates folder in the WooCommerce plugin and you will find a line in the very top comment describes how to override the file. Don’t forget … Read more

Merge multiple custom post types in a single archive template

As Jacob Peattle mentioned, you should not be using query_posts in your custom archive templates, that’s redundant as WP is already going to query those posts for you. What you really need is pre_get_posts (https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts). That will allow you to conditionally modify the parameters of the main query before it executes. Additionally since you are … Read more

get_template_part returns NULL

As the codex page of get_template_part() says: get_template_part doesn’t return a value and doesn’t warn if it fails to find a matching template file. Additionally: If you want to hear about failures, use: <?php assert( “locate_template( array(‘$name-$slug.php’, ‘$name.php’), true, false )” ); ?> So no wonder you are get nothing back. One thing I’m seeing … Read more

Placing the_content inside shortcode not working

It doesn’t appear that the variable $the_content exists. I’m guessing what you want is the function the_content(), but since that actually echoes its output, that won’t work either. You need to use the function get_the_content() which will return the output (as opposed to echoing it). Try this: echo do_shortcode(‘[wcm_restrict plans=”silver”]’ . get_the_content() . ‘[/wcm_restrict]’);

How to enqueue a theme style-sheet to my admin settings page?

The admin_enqueue_scripts hook has a $hook_suffix parameter for the current admin page. This parameter will return something like toplevel_page_yourpagename where the toplevel_page will be your page level and yourpagename is what you find on the ?page=yourpagename url. Use that to check if the current page is your plugin’s settings page and then load the scripts. … Read more