Why get_category() function is not working not working when embedded in a page?
This answer Count how many posts in category says to use this code $category = get_category($id); $count = $category->category_count;
This answer Count how many posts in category says to use this code $category = get_category($id); $count = $category->category_count;
Redefine arguments for ‘category’ taxonomy ONLY: add_filter( ‘get_terms_args’, ‘my_term_args’, 10, 2 ); function my_term_args( $args, $taxonomies ) { // don’t affect admin area passing back default arguments if ( is_admin() ) { return $args; } // check the taxonomy in use and redefine it’s default arguments if( in_array( ‘category’, $taxonomies ) ) { $args[‘orderby’] = … Read more
$args = array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘parent’ => 0 ); $categories = get_categories($args); May this will help you. Refer this link
I believe because: the_ID() : Display the ID of the current item in the WordPress Loop. and get_the_ID() : Retrieve the ID of the current item in the WordPress Loop. So the_ID() displays the post ID. Try to use get_the_ID()
In this line: $cats .= $category->name . ‘, ‘; You append a name of category to variable called $cats. But you never reset this variable. So every post appends its categories to the same variable. So here’s how to fix this: <?php $categories = get_the_terms($custom_args->ID, ‘veranstaltungen-category’); $cats=””; // set empty string as value foreach ($categories … Read more
The correct template to use in this case would be taxonomy-veranstaltungen-category.php, and that template needs to use the main loop. So, at a bare minimum you should have taxonomy-veranstaltungen-category.php with the following code: <?php get_header(); ?> <?php while ( have_posts() ) : the_post(); ?> <?php the_title(); ?> <?php endwhile; ?> <?php get_footer(); ?> That will … Read more
If you don’t want to include posts in child categories, use the category__in parameter: $args = array( ‘category__in’ => [ get_cat_ID( $category_name ) ], // use category__in //’category_name’ => $category_name, // and not this. ‘post_type’ => ‘menu’, ‘numberposts’ => -1, ‘post_status’ => ‘publish’ ); And although the above would give you what you wanted, the … Read more
get_the_category() should either be used within a (post) loop or with a $post_id parameter. In your code $cat_now is probably at the moment an empty array, so there’s nothing at the 0 position. Also, get_the_category() returns an array of WP_Term objects, which don’t have a property called category_parent, but just parent., which have parent property … Read more
You are headed down the right path, but your syntax I think is a tiny bit off. cat is in fact a public queryable variable. https://codex.wordpress.org/WordPress_Query_Vars#List_of_Query_Vars Rather than the +, you’ll need to use a , instead and you’ll need a & in there to split them up. You should see results on your search … Read more
Try to add the following code in functions.php of your theme and it should do the job. function dcg_tidy_rss_categories( $the_list ) { $categories = get_the_category(); $tags = get_the_tags(); if ( ! empty( $categories ) ) { foreach ($categories as $category) { // remove the following line if you don’t want Categories to appear $the_list = … Read more