WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] div within php tags (3 posts)

  1. pietergoosen
    Member
    Posted 1 year ago #

    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

  2. kevinhaig
    Member
    Posted 1 year ago #

    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 : ?>
  3. pietergoosen
    Member
    Posted 1 year ago #

    Hi kevin

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

Topic Closed

This topic has been closed to new replies.

About this Topic