Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php loop add class to first element

<div id="NewsCarousel" class="carousel slide">
<div class="carousel-inner">
<?php
$args = array( 'numberposts' => '2', 'category' => 5 );
$recent_posts = wp_get_recent_posts( $args );
$count = 0;
foreach( $recent_posts as $recent ){
$count++;
    echo '<div class="item'; if($count == 1){echo ' active';}"><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' . get_the_post_thumbnail($recent["ID"], array(200,200)) .$recent["post_title"].'</a> </div> ';
}
?>
</div>
</div>
Comment

PREVIOUS NEXT
Code Example
Php :: handling deadlocks laravel 
Php :: php edit user profile 
Php :: laravel find user by id 
Php :: multiple checked delete in laravel8 
Php :: php array reduce 
Php :: php exttends 
Php :: PHP code to redirect a user from a page to an alternate destination 
Php :: show data as per url slug change in laravel 
Php :: multiple laravel site in one directory 
Php :: section laravel append 
Php :: kill phpstorm process ubuntu 
Php :: detect change in log file in real time php 
Php :: acf if image else display other image 
Php :: insert three bars in php that are used to minimize and maximize pages 
Php :: set php version in php.ini 
Php :: installer composer dans ionos 
Php :: leggere file su piu righe php 
Php :: laravel chain query builder 
Php :: Writing into the database with one click laravel 
Php :: how to delete single row from grid in magento 
Php :: laravel login register api 
Php :: how to type casting and overriding in php 
Php :: Problems with Special Characters between Angular http post and PHP 
Php :: download yii 1.1 
Php :: ipv6 pregmatch 
Php :: laravel permit only some inputs 
Php :: how to set selected value in dropdown using php 
Php :: wp ajax error handling 
Php :: php script auf serve alle 5 minuten ausführen 
Php :: how to make login and logout to blog with php without database or MySQL 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =