How to display certain category in the loop from WordPress default post type?

Of course it displays all posts… You create your own custom WP_Query, but then you ignore it and use global one 😉 Here’s the correct code: <?php $args = array( ‘post_type’ => ‘post’, ‘category_name’ => ‘wedding-venue’, ‘posts_per_page’ => 8, ‘facetwp’ => true, ); $query = new WP_Query( $args ); ?> <?php if ( $query->have_posts() ) … Read more

Duplicated posts on category page

OK, so the code does exactly what it is supposed to. In your archive.php you do this: while ( have_posts() ) : the_post(); get_template_part( ‘loops/loop’, ‘archive’ ); So for every post (both of them) you include loops/loop-archive.php file. And inside that file you don’t display only the current post from global loop, but you make … Read more

Bypass “supress_filters” in WP Query

Looking at the WP_Query Class you should be able to use pre_get_posts to modify the query before any other filters are run, which includes turning off the suppress_filters flag. An example of this could be: /** * Modify WP_Queries * @link https://wordpress.stackexchange.com/q/356950/7355 * * @param WP_Query $query * * @return void */ function wpse356950_query_modifications( $query … Read more

add active class based on permalink and url

For the left side you could do this, <?php $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 10, ‘paged’ => get_query_var(‘paged’) ? get_query_var(‘paged’) : 1, ); $loop = new WP_Query( $args ); // add custom function before loop, so you can apply excerpt filter only to this case do_action(‘my_custom_pre_loop_action’); // is url parameter set, if … Read more