how to use custom loop in the_content filter
the_content is expecting a string, you’ll have to use output buffering: function my_custom_loop() { $taxonomy = ‘state_cat’; $terms = get_the_terms($post->ID, $taxonomy); if ($terms && ! is_wp_error($terms)) : $terms_array = array(); foreach ($terms as $term) { $terms_array[] = $term->slug; } $have_you_read_query = new WP_Query( array( ‘posts_per_page’ => 100, ‘post_type’ => ‘post’, ‘post__not_in’ => array($post->ID), ‘category__not_in’ => … Read more