Custom Post in WordPress -12

Custom Post in WordPress -12

Custom Post Type UI plugin is used to create custom post types and custom taxonomies. For this we use WP_Query class that accepts different parameters to request and fetch posts via those parameters. This is easily available and download from WordPress plugin by WebDevStudios. Example is given below for reference:

Custom Query for Post

<?php

$slider = new WP_Query(array(

    ‘posts_per_page’ => -1,

    ‘post_type’ => ‘slider_post’,

    ‘orderby’ => ‘date’,

    ‘order’ => ‘ASC’,

    ‘suppress_filters’ => true));

$counter = 0;

while ($slider->have_posts()) {

    $slider->the_post();

    ?>

<div class=”carousel-item <?php echo $counter == 0 ? “active” : “” ?>”>

</div>

<?php

$counter++;

}

wp_reset_query();

?>

One thought on “Custom Post in WordPress -12

Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

*

*