Support » Plugin: Insert PHP Code Snippet » Do loop work?

  • Hi, I am trying to use this code that works when I don’t use the plugin but doesn’t return any results using the snippet shortcode. I think maybe loops don’t work but I can’t tell from the docs. Sorry if this has been covered before

    ?>

    <div class=”btn-group”>
    <button type=”button” class=”btn btn-md btn-dark dropdown-toggle” data-toggle=”dropdown” aria-haspopup=”true” aria-expanded=”false”>
    Dropdown
    </button>
    <div class=”dropdown-menu”>
    <?php
    $args = array(
    ‘post_type’ => ‘product’,
    ‘posts_per_page’ => 12,
    ‘tax_query’ => array(
    array(
    ‘taxonomy’ => ‘product_visibility’,
    ‘field’ => ‘name’,
    ),
    ),
    );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post(); global $product;
    ?>
    post->ID ) ?>”><?php echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>
    <?php endwhile;
    wp_reset_query();
    ?>
    <div class=”dropdown-divider”></div>
    Separated link
    </div>
    </div><!– end button group –>

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Do loop work?’ is closed to new replies.