I have a PHP while loop and I'm trying to echo the contents of $child_i outside of it, how can I do this?
<li>
<div class="responsive-accordion-head"><span class="ico arrow-right"></span><?php the_sub_field('category_name'); ?> <span class="faq-counter">4 Questions</span></div>
<?php if( have_rows('questions') ): $child_i = 0; ?>
<!-- Trying to echo $child_i on the line below -->
<div class="responsive-accordion-panel <?php echo($child_i); ?>">
<?php while( have_rows('questions') ): the_row(); ?>
<div class="question">
<h6><?php the_sub_field('question'); ?></h6>
<p><?php the_sub_field('answer'); ?></p>
</div>
<?php $child_i++; endwhile; ?>
</div>
<?php endif; //if( get_sub_field('items') ): ?>
</div>
</li>
can put the results into your own array then access it via its number
<li>
<div class="responsive-accordion-head"><span class="ico arrow-right"></span><?php the_sub_field('category_name'); ?> <span class="faq-counter">4 Questions</span></div>
<?php if( have_rows('questions') ): $child_i = 0; ?>
<!-- Trying to echo $child_i on the line below -->
<div class="responsive-accordion-panel <?php echo($child_i); ?>">
<?php while( have_rows('questions') ): the_row(); ?>
<div class="question">
<h6><?php the_sub_field('question'); ?></h6>
<p><?php the_sub_field('answer'); ?></p>
</div>
<?php $results[] = $child_i; $child_i++; endwhile; ?>
</div>
<?php endif;
print_r($results);
//OR foreach($results as $result){echo $result;}
//OR echo $result[1].$result[1]; //etc
//if( get_sub_field('items') ): ?>
</div>
</li>
The easiest way to do this is to move your class inside your while() loop and then use the counter
Example
<li>
<div class="responsive-accordion-head"><span class="ico arrow-right"></span><?php the_sub_field('category_name'); ?> <span class="faq-counter">4 Questions</span></div>
<?php if( have_rows('questions') ): $child_i = 0; ?>
<!-- Trying to echo $child_i on the line below -->
<?php while( have_rows('questions') ): the_row(); ?>
<div class="responsive-accordion-panel <?php echo ($child_i); ?>">
<div class="question">
<h6><?php the_sub_field('question'); ?></h6>
<p><?php the_sub_field('answer'); ?></p>
</div>
</div>
<?php $child_i++; endwhile; ?>
<?php endif; //if( get_sub_field('items') ): ?>
</div>
</li>
Try to insert
echo '<xmp>'; var_dump($child_i); echo '</xmp>';
instead of
echo($child_i);
($child_i can contain an empty string)
Related
I have a standard wordpress blog here: http://webserver-meetandengage-com.m11e.net/insights/ and I've created a new category called clients.
The clients posts on this archive page will have different meta data that the standard blog post, so I want to get rid of the excerpt, date and author etc.
To achieve this I tried adding a conditional bit of code that said, IF the category of this post area is 'client' then echo style="display:none;" inside the div.
Here's the line of code I'm trying:
<p<?php if ( in_category( 'client' )) { echo 'style="display:none;"' }?>>This is not client</p>
Here's the loop it appears in:
<div class="container blog-card-container">
<div class="row">
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="col-md-4">
<a href="<?php the_permalink(); ?>">
<div class="card">
<div class="blog-thumb-container">
<?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?>
</div>
<div class="blog-clients-card-block">
<?php if( get_field('quote_name') ): ?><p class="client-name" style="color:<?php the_field('client_brand_colour'); ?>;"><?php the_field('quote_name'); ?></p><?php endif; ?>
<p<?php if ( in_category( 'client' )) { echo 'style="display:none;"' }?>>This is not client</p>
<p class="blog-cat-label"><?php the_category(', '); ?></p>
<h2 class="blog-card-title"><?php the_title(); ?></h2>
<p class="card-text"><?php the_excerpt(__('(more…)')); ?></p>
<p><strong><?php the_author(); ?></strong> | <?php the_date(); ?> </p>
</div>
</div>
</a>
</div>
<?php understrap_pagination(); ?>
<?php endwhile; wp_reset_postdata(); endif; ?>
</div>
</div>
But including it here breaks the loop and the page doesn't load... I'm not sure what I'm doing wrong, or even if there might be a better solution?
I essentially want to show one set of meta for post thumbnails with the category 'client' and then another set for all other categories in the blog.
I guess it could be IF category of container is client then show META1 else show META2.
Any help would be massively appreciated :)
Managed to achieve this with two IF ELSE statements:
<div class="container blog-card-container">
<div class="card-columns">
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink(); ?>">
<div class="card">
<!-- Image if loop =========================================== -->
<?php if ( in_category('14') ) : ?>
<div class="client-header-logo-card" style="background-color: <?php the_field('client_brand_colour'); ?>;">
<?php
$image = get_field('client_logo');
if( !empty($image) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>
</div>
<?php else: ?>
<div class="blog-thumb-container">
<?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?>
</div>
<?php endif ?>
<!-- Meta Data if loop =========================================== -->
<div class="blog-clients-card-block">
<?php if ( in_category('14') ) : ?>
<p class="blog-cat-label"><?php the_category(', '); ?></p>
<h2><?php the_title(); ?></h2>
<?php if( get_field('quote') ): ?><p class="client-quote"><?php echo custom_field_excerpt(); ?></p><?php endif; ?>
<?php if( get_field('quote_name') ): ?><p class="client-name" style="color:<?php the_field('client_brand_colour'); ?>;"><?php the_field('quote_name'); ?></p><?php endif; ?>
<?php if( get_field('quote_position') ): ?><p class="client-position" style="color:<?php the_field('client_brand_colour'); ?>;"><?php the_field('quote_position'); ?></p><?php endif; ?>
<?php if( get_field('button_text') ): ?>
<a class="btn btn-sm btn-client-archive" href="<?php the_permalink(); ?>" style="background-color:<?php the_field('client_brand_colour'); ?>;" role="button"><?php the_field('button_text'); ?></a>
<?php endif; ?>
<?php if( get_field('video_url') ): ?>
<div class="embed-container">
<?php the_field('video_url'); ?>
</div>
<?php endif; ?>
<?php else: ?>
<p class="blog-cat-label"><?php the_category(', '); ?></p>
<h2 class="blog-card-title"><?php the_title(); ?></h2>
<p class="card-text"><?php the_excerpt(__('(more…)')); ?></p>
<p><strong><?php the_author(); ?></strong> | <?php the_date(); ?> </p>
<?php endif ?>
</div>
</a>
</div>
You need to set it up in a Variable and echo the variable. For instance if client display:none is stored in the $style var if not then it doesn't place a style
<?php
if(in_category('client')){$style = 'display:none;';} else {$style = '';}
?>
<p style="<?php echo $style; ?>">This is not client</p>
<?php if( have_rows('team_members') ): ?>
<?php while( have_rows('team_members') ): the_row(); ?>
<div class="team-member-section">
<div class="container">
<?php if( get_row_layout() == 'team_members' ): ?>
<section class="team-member-section">
<?php
$team_title = get_sub_field('team_title');
$team_member = get_sub_field('team_member');
$description = get_sub_field('description');
?>
<div class="team-title">
<?php echo $team_title; ?>
</div>
<?php if( $team_member ): ?>
<?php if ( get_field('has_description') == 'yes') : ?>
<?php echo 'has_description'; ?>
<?php else : ?>
<?php echo 'has_no_description'; ?>
<?php endif; ?>
<?php endif; ?>
</section>
<?php endif; ?>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
It displays only the value "has_no_description", why is my true/false field not working and how to make it work so both situations will be displayed.
UPDATE:
<?php if( have_rows('team_members') ): ?>
<?php while( have_rows('team_members') ): the_row(); ?>
<div class="team-member-section">
<div class="container">
<?php if( get_row_layout() == 'team_members' ): ?>
<section class="team-member-section">
<?php
$team_title = get_sub_field('team_title');
$team_member = get_sub_field('team_member');
$description = get_sub_field('description');
?>
<div class="team-title">
<?php echo $team_title; ?>
</div>
<?php if( $team_member ): ?>
<?php if ( get_field('has_description') ) : ?>
<?php foreach( $team_member as $post): ?>
<?php setup_postdata($post); ?>
<div class="col-sm-4">
<div class="team-member">
<div class="member-img">
<?php the_post_thumbnail(); ?>
</div>
<h4><?php the_title(); ?></h4>
<?php the_content(); ?>
<?php echo "Has description"; ?>
<?php $overlay_text = get_field('overlay_text'); ?>
<?php if($overlay_text != ''): ?>
<div class="overlay-text">
<p><?php echo $overlay_text; ?></p>
</div>
<?php endif; ?>
</div>
</div>
<?php wp_reset_postdata(); ?>
<?php endforeach; ?>
<?php else : ?>
<?php foreach( $team_member as $post): ?>
<?php setup_postdata($post); ?>
<div class="col-sm-4">
<div class="team-member">
<div class="member-img">
<?php the_post_thumbnail(); ?>
</div>
<h4><?php the_title(); ?></h4>
<?php the_content(); ?>
<?php echo "Doesn not have description"; ?>
<?php $overlay_text = get_field('overlay_text'); ?>
<?php if($overlay_text != ''): ?>
<div class="overlay-text">
<p><?php echo $overlay_text; ?></p>
</div>
<?php endif; ?>
</div>
</div>
<?php wp_reset_postdata(); ?>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>
</section>
<?php endif; ?>
</div>
</div>
<?php endwhile; ?>
I posted my entire code.
I think the issue here is that the field 'has_description' is showed only on "Team" Custom Post Type and that's why the field is returning null, but I am not sure. Can someone make it work?
<?php if( have_rows('team_members') ): ?>
<?php while( have_rows('team_members') ): the_row(); ?>
<div class="team-member-section">
<div class="container">
<?php if( get_row_layout() == 'team_members' ): ?>
<section class="team-member-section">
<?php
$team_title = get_sub_field('team_title');
$team_member = get_sub_field('team_member');
$description = get_sub_field('description');
?>
<div class="team-title">
<?php echo $team_title; ?>
</div>
<?php if( $team_member ): ?>
<?php foreach( $team_member as $post): ?>
<?php if ( get_field('has_description') ) : ?>
<?php setup_postdata($post); ?>
<div class="col-sm-4">
<div class="team-member">
<div class="member-img">
<?php the_post_thumbnail(); ?>
</div>
<h4><?php the_title(); ?></h4>
<?php the_content(); ?>
<?php echo "Has description"; ?>
<?php $overlay_text = get_field('overlay_text'); ?>
<?php if($overlay_text != ''): ?>
<div class="overlay-text">
<p><?php echo $overlay_text; ?></p>
</div>
<?php endif; ?>
</div>
</div>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<div class="col-sm-4">
<div class="team-member">
<div class="member-img">
<?php the_post_thumbnail(); ?>
</div>
<h4><?php the_title(); ?></h4>
<?php the_content(); ?>
<?php echo "NOOOOOOO Description"; ?>
<?php $overlay_text = get_field('overlay_text'); ?>
<?php if($overlay_text != ''): ?>
<div class="overlay-text">
<p><?php echo $overlay_text; ?></p>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
</section>
<?php endif; ?>
</div>
</div>
<?php endwhile; ?>
It works like this, I moved the true/false <?php if ( get_field('has_description') ) : ?> field inside the foreach since true/false field belongs to the team custom post type, being out of the loop will always make it NULL
I can work pretty good with CSS and HTML but know nothing about PHP. I'm working on a wordpress client project and he wants more than one Latest Post/Recent Post to display on the static homepage. I'm pulling my hair out trying to figure this out. From the posted code, can someone show me what to delete and what to replace it with to make 5 of the most latest post appear? I really appreciate everyone's help.
<?php
/**
* Template Name: Homepage
*/
?>
<?php $mts_options = get_option(MTS_THEME_NAME); ?>
<?php get_header(); ?>
<?php if ($mts_options['mts_banner_show'] == '1') { ?>
<div class="b_first">
<div class="main-container">
<div class="container">
<div class="blog_first">
<!--first content-->
<div id="first_b">
<div class="b_right" <?php if ( isset( $_GET['mailchimp_signup'] ) || !empty( $_GET['aweber_signedup'] ) ) echo 'style="display:none;"'; ?>>
<h2 class="front-view-title">
<?php echo $mts_options['mts_banner_title']; ?>
</h2>
<div class="front-view-content">
<?php echo $mts_options['mts_banner_texts']; ?>
</div>
<?php if(!empty($mts_options['mts_button_text'])) { ?>
<div class="readMore" style="background:<?php echo $mts_options['mts_banner_button_bg']; ?>">
<?php echo $mts_options['mts_button_text']; ?>
<?php if(!empty($mts_options['mts_arrow_image'])) { ?>
<div class="b_dollor">
<img src="<?php echo $mts_options['mts_arrow_image']; ?>">
</div>
<?php } ?>
</div>
<?php } ?>
</div>
<!--Rightside Content-Option-1-->
</div>
<div id="second_b" <?php if ( !isset( $_GET['mailchimp_signup'] ) && empty( $_GET['aweber_signedup'] ) ) echo 'style="display:none;"'; ?>>
<div class="blog_first_alternative">
<h2 class="front-view-title">
<?php echo $mts_options['mts_banner_title']; ?>
</h2>
<div class="form_wrap">
<?php if(!empty($mts_options['mts_form_image'])) { ?>
<div class="form_wrap_left">
<img src="<?php echo $mts_options['mts_form_image']; ?>">
</div>
<?php } ?>
<div class="form_wrap_right">
<?php dynamic_sidebar('Home Subscribe Widget'); ?>
</div>
</div>
</div>
<!--Rightside content alternative option-->
<script type="text/javascript">
function hide_b() {
jQuery('#first_b').hide();
jQuery('#second_b').show();
}
</script>
</div>
</div>
<!--End of first content-->
</div>
</div>
</div>
<?php } ?>
<div class="main-container">
<div id="page">
<div class="artcl article">
<div id="content_box">
<?php if ($mts_options['mts_banner2_show'] == '1') { ?>
<!--Second Content-->
<div class="blog_second">
<div class="b_left">
<h2 class="front-view-title">
<?php echo $mts_options['mts_social_title']; ?>
</h2>
<?php if ( !empty($mts_options['mts_banner_social']) && is_array($mts_options['mts_banner_social'])) { ?>
<div class="social-icons">
<ul>
<?php foreach( $mts_options['mts_banner_social'] as $header_icons ) : ?>
<?php if( ! empty( $header_icons['mts_banner_icon'] ) && isset( $header_icons['mts_banner_icon'] ) ) : ?>
<li><span class="fa fa-<?php print $header_icons['mts_banner_icon'] ?>"></span></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
<?php } ?>
</div>
<div class="b_right">
<h2 class="front-view-title">
<?php echo $mts_options['mts_books_title']; ?>
</h2>
<div class="b_readings">
<ul>
<?php if(!empty($mts_options['mts_books_image'])){ ?>
<?php foreach( $mts_options['mts_books_image'] as $slide ) : ?>
<li> <?php echo wp_get_attachment_image( $slide['mts_book_image'], false, array('title' =>'') ); ?></li>
<?php endforeach; ?>
<li class="more-books"><?php echo $mts_options['mts_more_book_text']; ?><i class="fa fa-angle-double-right"></i></li>
<?php } ?>
</ul>
</div>
</div>
</div>
<?php } ?>
<?php if(!empty($mts_options['mts_featured_posts']) && !empty($mts_options['mts_featured_post_cat'])) { ?>
<div class="home_article">
<?php
$featured_cat = implode( ",", $mts_options['mts_featured_post_cat'] );
$featured_query = new WP_Query('cat='.$featured_cat.'&posts_per_page=5');
if ($featured_query->have_posts()) : while ( $featured_query->have_posts() ) : $featured_query->the_post(); ?>
<article class="latestPost featuredpost excerpt">
<!--Featured Post-->
<header>
<h3 class="title front-view-title"><?php echo get_the_category_by_ID($featured_cat); ?></h3>
<?php if(has_post_thumbnail()) { ?>
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>" id="featured-thumbnail">
<div class="featured-thumbnail">
<?php the_post_thumbnail('steadyincome-featured',array('title' => '')); ?> <?php if (function_exists('wp_review_show_total')) wp_review_show_total(true, 'latestPost-review-wrapper'); ?>
</div>
</a>
<?php } ?>
</header>
<div class="latestpost_wrap">
<h2 class="front-view-title">
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>
"><?php the_title(); ?></a>
</h2>
<?php mts_the_postinfo( 'home' ); ?>
<div class="front-view-content">
<?php echo mts_excerpt(45); ?>
</div>
<?php mts_readmore(); ?>
</div>
</article>
<?php endwhile; wp_reset_query(); endif; ?>
<?php $j = 0;
if (get_query_var('page') > 1) {
$paged = get_query_var('page');
} elseif (get_query_var('paged')) {
$paged = get_query_var('paged');
} else {
$paged = 1;
}
$args= array('paged' => $paged, 'post_type' => 'post');
query_posts($args);
if ( have_posts() ) : while ( have_posts() ) : the_post();?>
<?php if($j ==0){ ?>
<article class="latestPost latestpost excerpt">
<!--Latest Post-->
<header>
<h3 class="title front-view-title"><?php _e('Latest Post','steadyincome'); ?></h3>
<a href="<?php the_permalink() ?>" title="Menu widget article" id="featured-thumbnail">
<div class="featured-thumbnail">
<?php the_post_thumbnail('steadyincome-featured',array('title' => '')); ?>
<?php if (function_exists('wp_review_show_total')) wp_review_show_total(true, 'latestPost-review-wrapper'); ?>
</div>
</a>
</header>
<div class="latestpost_wrap">
<h2 class="front-view-title">
<?php the_title(); ?>
</h2>
<?php mts_the_postinfo( 'home' ); ?>
<div class="front-view-content">
<?php echo mts_excerpt(40); ?>
</div>
<?php mts_readmore(); ?>
</div>
</article>
<?php } ?>
<?php $j++; endwhile; wp_reset_query(); endif; ?>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
Looks like you might have some setting in your theme settings. However if you have no setting there.
You can see this line that is limiting latest posts to just one Post:
<?php if($j ==0){ ?>
You may try to change it to number you want to try and see if it loops more posts there:
<?php if($j < 5){ ?>
This should allow the loop to run for five posts now. Give it a try and see if it helps.
I've made a home page with four different categories to be shown.I think it was working well, but for now the all posts have the same content as the first post. Links, and featured images, are good, but text somehow is being overwritte.
Heress the screen all texts are the same:
http://imagizer.imageshack.us/v2/800x600q90/713/m1j6.jpg
Edited: so this works with <?php setup_postdata( $post ); ?> inside loops
My code:
<div class="bmw">
<h2>bmw news</h2>
<?php $k = 1;
$posts = get_posts('category=7&orderby=date&numberposts=2'); foreach($posts as $post) { ?>
<?php setup_postdata( $post ); ?>
<div id="home_post<?php if($k%2 == 0) echo "last" ;?>">
<?php if ( has_post_thumbnail() ) {?>
<a href="<?php the_permalink() ?>"><div id="img">
<span>
<?php the_post_thumbnail(); ?>
</span>
</div>
</a>
<?php }; ?>
<h3><?php the_title(); ?></h3>
<span id="tags"><?php the_tags(); ?></span>
<?php the_content('...'); ?>
<div class="button_more">Czytaj więcej<span><img style="vertical-align:middle;width:auto;margin-left:5%" src="http://test.startujac.pl/images/strzalka_czytaj_wiecej.png"></span></div>
</div>
<?php $k++; ?>
<?php } ?>
</div>
<div class="news">
<h2>VW news</h2>
<?php $v = 1;
$posts = get_posts('category=12&orderby=date&numberposts=2'); foreach($posts as $post) { ?>
<?php setup_postdata( $post ); ?>
<div id="home_post<?php if($v%2 == 0) echo "last" ;?>">
<?php if ( has_post_thumbnail() ) {?>
<a href="<?php the_permalink() ?>"><div id="img">
<span>
<?php the_post_thumbnail(); ?>
</span>
</div></a>
<?php } ?>
<h3><?php the_title(); ?></h3>
<span id="tags"><?php the_tags(); ?></span>
<?php the_content('...'); ?>
<div class="button_more">Czytaj więcej<span><img style="vertical-align:middle;width:auto;margin-left:5%" src="http://test.startujac.pl/images/strzalka_czytaj_wiecej.png"></span></div>
</div>
<?php $v++; ?>
<?php }?>
</div>
<div class="japan">
<h2>japan news</h2>
<?php $k = 1;
$posts = get_posts('category=13&orderby=date&numberposts=2'); foreach($posts as $post) { ?>
<?php setup_postdata( $post ); ?>
<div id="home_post<?php if($k%2 == 0) echo "last" ;?>">
<?php if ( has_post_thumbnail() ) {?>
<a href="<?php the_permalink() ?>"><div id="img">
<span>
<?php the_post_thumbnail(); ?>
</span>
</div></a>
<?php } ?>
<h3><?php the_title(); ?></h3>
<span id="tags"><?php the_tags(); ?></span>
<?php the_content('...'); ?>
<div class="button_more">Czytaj więcej<span><img style="vertical-align:middle;width:auto;margin-left:5%" src="http://test.startujac.pl/images/strzalka_czytaj_wiecej.png"></span></div>
</div>
<?php $k++; ?>
<?php } ?>
</div>
<div class="events">
<h2>imprezy i zloty</h2>
<?php $k = 1;
$posts = get_posts('category=1&orderby=date&numberposts=4'); foreach($posts as $post) { ?>
<?php setup_postdata( $post ); ?>
<div id="home_post<?php if($k == 1) echo "first" ;?>">
<?php if ( has_post_thumbnail() ) {?>
<div id="img">
<span>
<?php the_post_thumbnail(); ?>
</span>
</div>
<?php } ?>
<div id="content">
<h3><?php the_title(); ?></h3>
<span id="tags"><?php the_tags(); ?></span>
<?php the_content('...'); ?>
</div>
</div>
<?php $k++; ?>
<?php } ?>
</div>
Have you tried putting the_post(); on the beginning of your template file? This solves sometimes this kind of problems.
I have the following code:
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="item">
<?php the_post_thumbnail('full');?>
<div class="container">
<div class="carousel-caption">
<h1>
<?php the_title(); ?>
</h1>
<p>
<?php the_excerpt(); ?>
</p>
</div>
</div>
</div>
<?php endwhile; ?>
And I need to add the class "active" to the first div (next to "item")
Use a boolean variable to test, set it to true after first pass so that further loops will not mark it active
<?php $firstMarked = false; ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="item <?php echo !$firstMarked ? "active":"";?>">
<?php the_post_thumbnail('full');?>
<div class="container">
<div class="carousel-caption">
<h1>
<?php the_title(); ?>
</h1>
<p>
<?php the_excerpt(); ?>
</p>
</div>
</div>
</div>
<?php $firstMarked = true;?>
<?php endwhile; ?>
Add a flag:
<?php
$isFrist = true;
while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="item">
<?php the_post_thumbnail('full');?>
<div class="container<?php if ($isFirst): ?> active<?php endif ?>">
<div class="carousel-caption">
<h1>
<?php the_title(); ?>
</h1>
<p>
<?php the_excerpt(); ?>
</p>
</div>
</div>
</div>
<?php
$isFrist = false;
endwhile;
?>
if($loop->current_post == 1){
echo 'class';
}
<script type="text/javascript">
$('.carousel-inner > :first-child').addClass("active");
</script>