Limit Category/Tag Dropdown To blog_id in Multisite Install With Global Categories/Tags

The wp_dropdown_category seems to not accept the mera_query parameter codex Maybe you must perform à special query , note that the meta_query must be an array of array. ‘meta_query’=> array( array( ‘key’ => ‘blog_id’, ‘value’ => $blog_id, ‘compare’ => ‘=’ ) ), With the new query you’ll be able to compose your dropdown by looping … Read more

Different template for subcategories

The template hierarchy has filters for all types of templates. Here we can use category_template, check if the current category has a parent, and load the subcategory.php file in that case: function wpd_subcategory_template( $template ) { $cat = get_queried_object(); if ( isset( $cat ) && $cat->category_parent ) { $template = locate_template( ‘subcategory.php’ ); } return … Read more

Issue with WordPress category search

You can search post by modify the query using pre_get_post filter. add this code inside your functions.php file add_filter(‘pre_get_posts’, ‘search_by_category’); function search_by_category($wp_query) { if (isset($_GET[‘cat’]) && !is_admin()) { $wp_query->set(‘category__in’, array($_GET[‘cat’])); } } Before using any query variable you must have to register/add using add_query_var. function add_category_query_string() { global $wp; $wp->add_query_var(‘cat’); } add_filter(‘init’, ‘add_category_query_string’); let me … Read more

How to display child-category PAGES on a category page

<?php get_header(); $cb_cats = get_the_category(); $cb_cat_id = get_query_var(‘cat’); $cb_blog_style = cb_get_blog_style(); $cb_cat_title_bg = $cb_tax_id = $cb_taxonomy = $cb_tax_qry = NULL; $cb_archive_title_bg_src = cb_archive_title_bg(); if ( function_exists(‘get_tax_meta’) ) { $cb_category_color_style = get_tax_meta($cb_cat_id, ‘cb_cat_style_color’); $cb_featured_option = get_tax_meta($cb_cat_id, ‘cb_cat_featured_op’); $cb_category_ad = get_tax_meta_strip($cb_cat_id, ‘cb_cat_ad’); $cb_category_color = get_tax_meta($cb_cat_id, ‘cb_color_field_id’); if ( ($cb_category_color == ‘#’ ) || ( $cb_category_color == NULL … Read more

Most efficient way to display current post subcategories?

After looking at get_the_terms() again I think I found a better solution: functions.php global $reviews_cat_id_brand; $reviews_cat_id_brand = 158; // using # in case string changes if( !function_exists(‘reviews_print_subcat_link’) ){ function reviews_print_subcat_link($cat_id){ $items = get_the_terms(get_the_ID(), ‘review-category’); $subcat_array = []; foreach ($items as $item) { if($item->parent === $cat_id) { $subcat_array[] = ‘<a href=”‘.get_term_link($item).'”>’.$item->name.'</a>’; } } return $subcat_array; } … Read more

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