Need to add class to first element in a foreach loop

Use below code <?php $isFirst = true; $i=1; foreach ( $attachments as $attachment ): $description = $attachment->post_content; if($i==1) { echo ‘<div class=”item’.$isFirst.'” data-description=”‘ . $description . ‘”>’; echo wp_get_attachment_image($attachment->ID, ‘large’); echo ‘</div>’; } else { echo ‘<div class=”item” data-description=”‘ . $description . ‘”>’; echo wp_get_attachment_image($attachment->ID, ‘large’); echo ‘</div>’; } $i++; endforeach; ?>

WordPress + Bootstrap [closed]

As far as I’ve seen you’re missing bootstrap CSS grid markup inside your page div, so to start add container class to page div and below that a .row element, for more inforamation on how the Bootstrap grid works check documantation and remember that all Js and styles are based on the correct markup selectors_

While loop with bootstrap [closed]

Try using the count variable to increment the loop. <div class=”panel-group” id=”accordion” role=”tablist” aria-multiselectable=”true”> <?php if(get_field(‘faq_general_ht’)): ?> <?php $count=0; ?> <?php while(has_sub_field(‘faq_general_ht’)): ?> <div class=”panel panel-default”> <div class=”panel-heading” role=”tab” id=”headingTwo”> <h4 class=”panel-title”> <?php echo ‘<a data-toggle=”collapse” data-parent=”#accordion” href=”#collapse’ .$count. ‘”aria-expanded=”true”>’ ?> <p><?php the_sub_field(‘faq_general_question_ht’) ?></p> </a> </h4> </div> <?php echo ‘<div id=”collapse’ .$count. ‘” class=”panel-collapse collapse” … Read more

add bootstrap post slider with tabs

There’s probably some better way of doing this, but thought i’d give it a go anyways 🙂 – also got some of the answer from here Adding active class to first item <div class=”container”> <div id=”myCarousel” class=”carousel slide” data-ride=”carousel”> <!– Wrapper for slides –> <div class=”carousel-inner”> <?php $c = 0; $class=””; $args = array( ‘posts_per_page’ … Read more

Adding bootstrap classes to video shortcodes

This is how I bootstrapped youtube embeds in one of my projects. /** * Responsive Youtube embeds. */ add_filter( ’embed_oembed_html’, function( $html, $url, $attr, $post_ID ) { if ( false !== stripos( $html, ‘<iframe ‘ ) && false !== stripos( $html, ‘.youtube.com/embed’ ) ) { $html = sprintf(‘<div class=”embed-responsive embed-responsive-16by9″>%s</div>’, $html ); } return $html; … Read more

How to create bootstrap grid loop?

Okay I got it! And this code works perfectly for me. 🙂 <?php $args=array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 4, ‘paged’ => $paged, ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_format’, ‘field’ => ‘slug’, ‘terms’ => array(‘post-format-video’), ‘operator’ => ‘IN’) ) ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { $i = 0; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)