Exclude the category in WordPress

If retrieve_cat_data_sp is the function from this question then that returns categories except the ones given in the argument: $cat_lists = retrieve_cat_data_sp(’81’); It essentially a wrapper for get_categories. So to exclude multiple Ids $cat_lists = retrieve_cat_data_sp(‘81,82’); If you want to exclude 81 as well as those IDs listed in get_option(‘bn_exclude_home_lists’) then, assuming that option returns … Read more

Exclude current post ID from loop in sidepbar.php

First, do not use query_posts() for secondary loops. The query_posts() function is intended only to modify the primary loop query. Use WP_Query() or get_posts() for secondary loop queries. Also, showposts is deprecated. Use posts_per_page instead. Let’s use WP_Query(), as it will be the most analogous to your current implementation: <?php // First, let’s eliminate some … Read more

problems exluding categories

Don’t use query_posts(). Filter pre_get_posts instead: function wpse65927_filter_pre_get_posts( $query ) { // If this is the blog posts index, // and if this is the main query, // exclude category 6 if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘cat’, ‘-6’ ); } } add_action( ‘pre_get_posts’, ‘wpse65927_filter_pre_get_posts’ ); Put the above hook and callback in … Read more

Homepage custom recent news

Assuming this is the default main query, see the example for pre_get_posts, which shows how to exclude a category from the main query: function wpa78465_exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘cat’, ‘-1,-1347’ ); // IDs of categories to exclude } } add_action( ‘pre_get_posts’, ‘wpa78465_exclude_category’ );

WooCommerce Hiding A Certain Category From Being Displayed On Single Product

You are right about woocommerce: get_categories() being different from wordpress: get_categories(), the woocommerce function uses get_the_term_list(), so there is no way to exclude categories, same applies to get_the_category_list(). You can use wp_list_categories() for this, especially take a look at this example from the codex page: Display Categories Assigned to a Post Display the categories (or … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)