Last active
September 28, 2021 20:46
-
-
Save nickberens360/29dbdb0924ebaebce228 to your computer and use it in GitHub Desktop.
wordpress: Full dynamic bootstrap carousel code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> | |
<ol class="carousel-indicators"> | |
<?php | |
$args = array( | |
'post_type' => 'slides1', | |
'orderby' => 'menu_order title', | |
'order' => 'ASC', | |
); | |
$query = new WP_Query( $args ); | |
?> | |
<?php if($query->have_posts()) : ?> | |
<?php $i = 0; ?> | |
<?php while($query->have_posts()) : $query->the_post() ?> | |
<li data-target="#carousel-example-generic" data-slide-to="<?php echo $i ?>" class="<?php if($i === 0): ?>active<?php endif; ?>"></li> | |
<?php $i++; ?> | |
<?php endwhile ?> | |
<?php endif ?> | |
<?php wp_reset_postdata(); ?> | |
</ol> | |
<div class="carousel-inner" role="listbox"> | |
<?php | |
$args = array( | |
'post_type' => 'slides1', | |
'orderby' => 'menu_order title', | |
'order' => 'ASC', | |
); | |
$query = new WP_Query( $args ); | |
?> | |
<?php if($query->have_posts()) : ?> | |
<?php $i = 0; ?> | |
<?php while($query->have_posts()) : $query->the_post() ?> | |
<div class="item <?php if($i === 0): ?>active<?php endif; ?>"> | |
<img src="<?php the_field('slide_image'); ?>" alt=""> | |
</div> | |
<?php $i++; ?> | |
<?php endwhile ?> | |
<?php endif ?> | |
<?php wp_reset_postdata(); ?> | |
</div> | |
<!-- Controls --> | |
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev"> | |
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> | |
<span class="sr-only">Previous</span> | |
</a> | |
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next"> | |
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> | |
<span class="sr-only">Next</span> | |
</a> | |
</div> |
can you make the same for "Bootstrap 4" which is the latest in 2018?
Hi,.. Nice work. Can you make it same in bootstrap 4 ?
Hi,.. Nice work. Can you make it same in bootstrap 4 ?
I think the only thing you would need to change is the class name "item" to "carousel-item".
thank you Nick
…On Wed, Jun 5, 2019 at 12:36 AM Nick Berens ***@***.***> wrote:
Hi,.. Nice work. Can you make it same in bootstrap 4 ?
I think the only thing you would need to change is the class name "item"
to "carousel-item".
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://gist.github.com/29dbdb0924ebaebce228?email_source=notifications&email_token=AME54DGGISMRKCGFFPQIOLDPY24M3A5CNFSM4HS245N2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFTEHW#gistcomment-2934907>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AME54DBQOV2LD6L5YLHFAZLPY24M3ANCNFSM4HS245NQ>
.
--
Thanks & Regards,
*UDAYAKUM**AR K*
Business Development Consultant
PH : 86 06 04 05 02
www.udayakumar.info
Thank you for your code
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
why wordpress single php does not work in bootstrap carousel
functions.php
//custome post register_nav_menus
add_action( 'init', 'custom_bootstrap_slider' );
/**
Register a Custom post type for.
*/
function custom_bootstrap_slider() {
$labels = array(
'name' => _x( 'Slider', 'post type general name'),
'singular_name' => _x( 'Slide', 'post type singular name'),
'menu_name' => _x( 'Bootstrap Slider', 'admin menu'),
'name_admin_bar' => _x( 'Slide', 'add new on admin bar'),
'add_new' => _x( 'Add New', 'Slide'),
'add_new_item' => __( 'Name'),
'new_item' => __( 'New Slide'),
'edit_item' => __( 'Edit Slide'),
'view_item' => __( 'View Slide'),
'all_items' => __( 'All Slide'),
'featured_image' => __( 'Featured Image', 'text_domain' ),
'search_items' => __( 'Search Slide'),
'parent_item_colon' => __( 'Parent Slide:'),
'not_found' => __( 'No Slide found.'),
'not_found_in_trash' => __( 'No Slide found in Trash.'),
);
$args = array(
'labels' => $labels,
'menu_icon' => 'dashicons-star-half',
'description' => __( 'Description.'),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => true,
'menu_position' => null,
'supports' => array('title','editor','thumbnail')
);
register_post_type( 'slider', $args );
}