get_category_parents displays an empty category

How do I remove the last, empty category without PHP functions like explode or substr? You don’t. Look at the source: http://core.trac.wordpress.org/browser/tags/3.6.1/wp-includes/category-template.php#L42 The output you see is intended behavior and there is no filter. My guess is that you are trying to use the function for something it is not meant for. You could take … Read more

Pluck single parent category from get_the_category

You can check the category ‘parent’ arribute, and if is 0 the category is a parent one. I’ve also noted some things on your code: When the is is passed get_the_category is unused, but it is called anyway You use get_the_category assuming function are called in the loop, but there is no check for that … Read more

Create Cross Promoting Categories in WordPress Using ‘pre_get_posts’

I think I remember seeing this attempt somewhere… If I remember correctly, the solution was to use a custom tax query on the category.php template, but querying the taxonomy (crosspostcategory) FIRST in the “or” statement… So you’d check for the taxonomy first, and then query (tax query) the category taxonomy next in the OR statement. … Read more

Category slug in in loop always the same?

First, Please don’t use query_posts.. Second, you’ve set $category somewhere in code not posted and never change it. How do you expect it to be different? What you need to do is retrieve the categories, which isn’t that hard… $cq = new WP_Query(‘category__in=4′); while ( $cq->have_posts() ) { $cq->the_post(); $c = wp_get_object_terms($post->ID,’category’); var_dump($c); // echo … Read more

Printing direct descendants of a category with WP_Query

From the Codex: child_of (integer) Display all categories that are descendants (i.e. children & grandchildren) of the category identified by its ID. There is no default for this parameter. If the parameter is used, the hide_empty parameter is set to false. And… parent (integer) Display only categories that are direct descendants (i.e. children only) of … Read more

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