Show post excerpt

One option would be to use substr in your function: function my_excerpt($limit) { $excerpt = get_the_excerpt(); if(strlen($excerpt) > $limit) { // trim to $limit characters $excerpt = substr($excerpt, 0, $limit); // remove any truncated words $excerpt = substr($excerpt, 0, strippos($excerpt, ” “)); $excerpt = trim(preg_replace(‘/\s+/’, ‘ ‘, $excerpt)); } return $excerpt; } Another way is … Read more

Display new posts categories in separated divs

You should first make a query to retrieve all your categories. This can be done using: $categories = get_categories(array(‘hide_empty’=> 0,)); Now that you have a list of your categories as object, you have to run a foreach to output their content: foreach ($categories as $category) { $params = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘product’, … Read more

How to prevent post to repeat on my loop?

As mentioned in comment by @Michael, offset does not work with ‘posts_per_page’ => -1 You can possibly use increment to make first slide as active, in a single loop. Use this <div class=”carousel-inner” role=”listbox”> <?php $the_query = new WP_Query(array( ‘post_type’ => ‘Banners’, ‘posts_per_page’ => -1 )); $i = 0; while ( $the_query->have_posts() ) : $the_query->the_post(); … Read more

Why is my query not giving results?

Thanks for comments, It has been fixed by replacing ‘type’ => ‘DATE’ with ‘type’ => ‘NUMERIC’ I hope this will be helpfull. I adding link where I finded my answer https://gist.github.com/billerickson/3698476#file-gistfile1-php