Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Ticket #17725
- // File template: /themes/isipp/lib/isipp-visual-composer-elements.php
- // line: 62 - 176
- /* Custom Blog Post */
- vc_map(array(
- "name" => __("News Grid"),
- "base" => "news_post_shortcode",
- "category" => __('Content'),
- "params" => array(
- )
- ));
- add_shortcode('news_post_shortcode', 'news_post_section');
- function news_post_section($atts) {
- ob_start();
- global $wpdb, $post;
- $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
- $news_args = array (
- 'posts_per_page' => 8,
- 'paged' => $paged,
- 'post_type' => 'post',
- 'post_status' => 'publish',
- );
- $news_query = new WP_Query($news_args);
- echo '<div class="news-article-secteion">';
- if ($news_query->have_posts()) {
- $i = 0;
- while ($news_query->have_posts()) {
- $news_query->the_post();
- $postID = get_the_id();
- // Product Title
- $postTitle = get_the_title($post->ID);
- $postContent = get_the_content($post->ID);
- // strip all shortcodes but keep content
- $the_content = preg_replace("~(?:\[/?)[^/\]]+/?\]~s", '', $postContent);
- $getCategories = load_terms('category');
- if($i == 2) {
- echo '<div class="news-item categories-section">';
- echo '<h4>Categories</h4>';
- echo '<ul class="catgories_list">';
- if(!empty($getCategories)) {
- foreach($getCategories as $caetgory) {
- $catURL = site_url().'/category/'.$caetgory->slug;
- echo '<li><a href="'.$catURL.'">'.$caetgory->name.'</a></li>';
- }
- }
- echo '</ul>';
- echo '</div>';
- }
- echo '<div class="news-item">';
- if(!empty(get_the_post_thumbnail( $post->ID, 'medium' ))) {
- echo '<a href="'.get_the_permalink($post->ID).'" target="_self">'.get_the_post_thumbnail( $post->ID, 'medium' ).'</a>';
- } else {
- echo '<a href="'.get_the_permalink($post->ID).'" target="_self"><img src="'.site_url().'/wp-content/uploads/2021/06/content-5.jpg"></a>';
- }
- echo '<a href="'.get_the_permalink($post->ID).'" target="_self"><h4>'.get_the_title($post->ID).'</h4></a>';
- echo '<div class="content">'.wp_trim_words($the_content, 55, '...').'</div>';
- echo '<a class="read_more_btn" href="'.get_the_permalink($post->ID).'" target="_self">READ MORE</a>';
- echo '</div>';
- $i++;
- }
- }
- echo '</div>';
- wp_reset_postdata();
- wp_reset_query();
- ?>
- <div class="news-pagination">
- <?php
- $big = 999999999; // need an unlikely integer
- echo paginate_links( array(
- 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
- 'format' => '?paged=%#%',
- 'current' => max( 1, get_query_var('paged') ),
- 'total' => $news_query->max_num_pages
- ) );
- ?>
- </div>
- <?php
- $output = ob_get_contents();
- ob_end_clean();
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement