custom post register and dynamic
custom slider
//custom post register bellow use this code functions.php
function neuron_theme_custom_post() {
register_post_type( 'slide',
array(
'labels' => array(
'name' => __( 'Sliders' ),
'singular_name' => __( 'Slide' )
),
'supports' => array('title', 'editor', 'custom-fields', 'thumbnail', 'page-attributes'),
'public' => false,
'show_ui' =>true
)
);
}
add_action( 'init', 'neuron_theme_custom_post');
..............................
//this code is index.php
<section class="slider-area">
<?php
global $post;
$args = array( 'posts_per_page' => 10, 'post_type'=> 'slide', 'orderby' => 'menu_order', 'order' => 'ASC' );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<?php
$btn_text= get_post_meta($post->ID, 'btn_text', true);
$btn_link= get_post_meta($post->ID, 'btn_link', true);
?>
<div style="background-image: url(<?php the_post_thumbnail_url('large' ); ?>);" class="homepage-slider">
<div class="display-table">
<div class="display-table-cell">
<div class="container">
<div class="row">
<div class="col-sm-7">
<div class="slider-content">
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<a href="<?php echo $btn_link; ?>"><?php echo $btn_text; ?> <i class="fa fa-long-arrow-right"></i></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; wp_reset_query(); ?>
</section><!-- slider area end -->
No comments