WordPress CPT Url metabox collection

you can add a parameter with a new rewrite rule like that : add_action(“init”, function () { add_rewrite_tag(“%countryName%”, “([^&]+)”); add_rewrite_rule( “^company/([^/]*)/country/([^/]*)/?” , ‘index.php?company=$matches[1]&countryName=$matches[2]’ , “top” ); }); After adding this code, flush the rewrite rules of WordPress. Then you can use URL like http://example.com/company/company-abc/country/UK And then in the template, you retrieve the parameter with get_query_var(“countryName”, … Read more

How to add php plugin code in theme

If you, for some reason, don’t want to use the shortcode ([ratings]), you can always use the_ratings() directly in your template. Make sure you are within the loop so it’ll be able to identify the correct post ID for you. If you want to use it outside the loop, you can pass your ID manually. … Read more

Hide ‘add to cart’ button for some products [duplicate]

I don’t know whether my solution is perfect. But it works. Normally if is_purchasable is returned to the filter woocommerce_is_purchasable, the ‘Add to Cart’ button is displayed, and if false is returned the button is hidden. So, you just need to add the following: add_filter(‘woocommerce_is_purchasable’, ‘my_woocommerce_is_purchasable’, 10, 2); function my_woocommerce_is_purchasable($is_purchasable, $product) { // Write code … Read more