Function.php // write code in function page
add_action( 'init', 'slider_home' );
function slider_home() {
register_post_type( 'slider_home',
array(
'labels' => array(
'name' => 'Slider',
'singular_name' => 'Slider',
'add_new' => 'Add New',
'add_new_item' => 'Add New Slider',
'edit' => 'Edit',
'edit_item' => 'Edit Slider',
'new_item' => 'New Slider',
'view' => 'View',
'view_item' => 'View Slider',
'search_items' => 'Search Slider',
'not_found' => 'No Slider found',
'not_found_in_trash' => 'No Slider in Trash',
'parent' => 'Parent Slider'
),
'public' => true,
'menu_position' => 15,
'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ),
'taxonomies' => array( '' ),
'menu_icon' => admin_url( 'images/why_choose.png', __FILE__ ),
'has_archive' => true
)
);
}
home page/ header.php // where you want to run slider
<ul>
<?php $args = array('post_type' => 'slider_home' );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<li>
<div class="slide-body" data-group="slide">
<div class="container">
<div class="wrapper">
<?php
$slider1_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
?>
<div class="caption person" data-animate="slideAppearLeftToRight" data-delay="800"> <img src="<?php echo $slider1_image; ?>" alt="Person"> </div>
<div class="caption problem_solved" data-animate="slideAppearLeftToRight">
<?php echo $post->post_content; ?>
<a href="<?php the_permalink($post->ID); ?>">read more</a>
</div>
</div>
</div>
</div>
</li>
<?php endforeach;
wp_reset_postdata();?>
</ul>
add_action( 'init', 'slider_home' );
function slider_home() {
register_post_type( 'slider_home',
array(
'labels' => array(
'name' => 'Slider',
'singular_name' => 'Slider',
'add_new' => 'Add New',
'add_new_item' => 'Add New Slider',
'edit' => 'Edit',
'edit_item' => 'Edit Slider',
'new_item' => 'New Slider',
'view' => 'View',
'view_item' => 'View Slider',
'search_items' => 'Search Slider',
'not_found' => 'No Slider found',
'not_found_in_trash' => 'No Slider in Trash',
'parent' => 'Parent Slider'
),
'public' => true,
'menu_position' => 15,
'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ),
'taxonomies' => array( '' ),
'menu_icon' => admin_url( 'images/why_choose.png', __FILE__ ),
'has_archive' => true
)
);
}
home page/ header.php // where you want to run slider
<ul>
<?php $args = array('post_type' => 'slider_home' );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<li>
<div class="slide-body" data-group="slide">
<div class="container">
<div class="wrapper">
<?php
$slider1_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
?>
<div class="caption person" data-animate="slideAppearLeftToRight" data-delay="800"> <img src="<?php echo $slider1_image; ?>" alt="Person"> </div>
<div class="caption problem_solved" data-animate="slideAppearLeftToRight">
<?php echo $post->post_content; ?>
<a href="<?php the_permalink($post->ID); ?>">read more</a>
</div>
</div>
</div>
</div>
</li>
<?php endforeach;
wp_reset_postdata();?>
</ul>
No comments :
Post a Comment