• Resolved alitscha

    (@alitscha)


    Hi I have a a custom post type loop inside a page template, which is coded like that

    <?php $args = array( 'post_type' => 'partners' );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
    echo '<div class="partner-name">';
      the_title();
      echo '</div>';
      echo '<div class="entry-content">';
      the_content();
      echo '</div>';
    endwhile; ?>

    Where should I place the do_action hook to show the custom taxonomies I created? If I add it before endwhile it doesn’t work.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jonathandejong

    (@jonathandejong)

    Hi,

    You can place the do_action call anywhere you want as long as you also specify the post type slug as a second parameter. However note that the visitor will always be directed to the post type archive when doing a filter.. BTF does not work with custom loops (it’d be impossible).

    Thread Starter alitscha

    (@alitscha)

    I see! I had actually solved the issue in the meanwhile but if I can’t use it in custom loop, then maybe the plugin is not the solution for my problem. I need two different custom post archives in the same page, I guess this is only possible with custom loops…thanks anyway!

    Plugin Author Jonathandejong

    (@jonathandejong)

    Hi,

    Not necessarily. It’s absolutely possible to have different post type archives in the same page. But just make sure you use the default wp_query for the one which should be filtered with BTF.

    The other can easily be a custom wp_query with your own loop in the same template (archive.php or cptslug-archive.php).

    But do it the way it works for you! There’s rarely only one right answer to solving code ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Post type loop in template and do_action’ is closed to new replies.