category filter doesn’t work

this is the problem, starting at line 46: $args = array( ‘post_type’ => ‘post’ ); $post_query = new WP_Query($args); if($post_query->have_posts() ) { while($post_query->have_posts() ) { $post_query->the_post(); //stuff endwhile; endif; you’re not using the original query for the page, which contains just posts from the current category, and you’re replacing it with a new query that’s … Read more

how to call the category of the post

Well first off, that code’s a mess to read, some formatting would definitely help get you an answer. That said, here’s the documentation on WP_Query and some sample code to boot $args = array( ‘post_status’ => ‘publish’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => ‘your_cat_slug’ ) ) ); $posts = … Read more

Get Child category “name” of post

menardmam, this is my solution: <?php $showPostsInCategory = new WP_Query(); $showPostsInCategory->query(‘cat=”. $carouselCategory .”&showposts=”. $carouselNumber .”‘); if ($showPostsInCategory->have_posts()) : while ($showPostsInCategory->have_posts()) : $showPostsInCategory->the_post(); ?> <li> <?php $data = get_post_meta( $post->ID, ‘key’, true ); ?> <?php foreach((get_the_category()) as $category) {echo ( $category->cat_name != $carouselCategory ) ? $category->cat_name . ‘ ‘ : ”;}?> <a href=”https://wordpress.stackexchange.com/questions/45198/<?php if ($data[“custom_link’ ]) … Read more