WordPress Related Posts by Title and Category

Probably the simplest approach is to combine the category query with a search query (untested): $cat_query = new WP_Query( array( ‘cat’ => $cat_id, ‘post__not_in’ => array( get_the_ID() ), ‘no_found_rows’ => false, ‘posts_per_page’ => 6, ) ); $title_query = new WP_Query( array( ‘post__not_in’ => array( get_the_ID() ), ‘s’ => get_the_title(), ‘no_found_rows’ => false, ‘posts_per_page’ => 6, … Read more

Remove product meta from single product page

If the code you provided is not working for other themes, it’s possible that the hooks or actions used by those themes are different. To remove product categories from the single product page using PHP, you can try the following code: function remove_product_meta() { remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_meta’, 40 ); } add_action( ‘init’, ‘remove_product_meta’ ); This … Read more

Fetch Post Category

If you want to display and fetch all post categories that have posts associated with them and display them in a dropdown list in the WP admin panel, try below the code add in code to your themes functions.php file or in a custom plugin. function get_categories_with_posts() { // Get all categories that have posts … Read more

Restricted category in Woocommerce [closed]

The function that solves it should do the following : Loops through each product in the category For each item, retrieve the list of categories the product is in. If there is only one category and it’s the ‘restricted’ category, then the product is excluded from the query. Here’s an example : function exclude_category_archive_products( $q … Read more