Support » Fixing WordPress » div within php tags

  • Resolved pietergoosen

    (@pietergoosen)


    Hi there

    I would like to put a div around the folowing part switch ( $list_style ) {} in the code below

    <?php endif;
    while ( $wp_query->have_posts() ) :
    $wp_query->the_post();
    
    switch ( $list_style ) {very long coding, in short get_post_format or custom post formats}
    endwhile;
    else : ?>

    Any ideas. I did try to echo it outside the php tag, but it is not working. I’m still learning wordpress, so any help will be appreciated.

    Many thank

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try this :

    <?php endif;
    while ( $wp_query->have_posts() ) :
    $wp_query->the_post();
    echo '<div class="your-class">';
    switch ( $list_style ) {very long coding, in short get_post_format or custom post formats}
    echo '</div>';
    endwhile;
    else : ?>

    Thread Starter pietergoosen

    (@pietergoosen)

    Hi kevin

    Many thanks for you solution. Works perfectly. Now I can start to work on the css grid. Again, many thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘div within php tags’ is closed to new replies.