• paulwv

    (@paulwv)


    I have the Univermag template with WordPress 4.4.2.

    I want to combine the sticky posts with the actual news posts. Because the way it’s setup now, sticky posts are only on top and news posts are on the bottom.

    I need to have the sticky posts also show in the middle with the posts, by combined order of date. The posts are already showing by date, but I need the stick posts to show by date also.

    <?php
    global $dankovData;
    $count = 0;
    $sidebarOff = ( isset($dankovData['blog_sidebar_position']) && $dankovData['blog_sidebar_position'] != null ) ? $dankovData['blog_sidebar_position'] : 'sidebar-right'; ?>
    <?php get_header(); ?>
        <div class="container cont-wide">
                <div class="row" data-sticky_parent>
                <div class="col-lg-2 col-left <?php echo $sidebarOff; ?>">
    
                    <?php if ( is_active_sidebar( 'sidebar-mini' ) ) : ?>
                        <div class="sidebar sidebar-mini">
                            <?php dynamic_sidebar( 'sidebar-mini' ); ?>
                        </div>
                        <?php else: ?>
                        <div class="sidebar sidebar-mini">
                            <div class="widget-line"><h3 class="widget-title">Mini Sidebar</h3></div>
                                <div class="textwidget">Mini sidebar for ads and other widgets</div>
                        </div>
                    <?php endif; ?>
    
                    </div>
    
                    <div class="col-lg-6 col-md-7 col-cus-7 col-sm-12 col-content <?php echo $sidebarOff; ?>" data-sticky_column>
                        <div class="wrap-content">
                        <!-- royal slider -->
                        <?php
                            /*-------------------------------------------
                                2.1 - Featured Posts
                            -------------------------------------------*/
    
                            if ( get_option('sticky_posts') ) {
    
                                $rsquery_args = array(
                                    'post__in'              => get_option('sticky_posts'),
                                    // 'posts_per_page'        =>
                                    'order'                 => 'DESC',
                                    'orderby'               => 'date',
                                    'paged'                 => 1,
                                    'post_status'           => 'publish',
    								'ignore_sticky_posts'   => 'false',
    
                                );
    
                                /*--- Loop -----------------------------*/
    
                                $rsliderQuery = new WP_Query( $rsquery_args ); ?>
    
                                    <div class="posts-featured-wrapper slider-main">
    
                        <?php if ($rsliderQuery->have_posts()) : ?>
                                        <div id="dankov-video-gallery" class="royalSlider videoGallery rsDefault">
                        <?php
                                            while ( $rsliderQuery->have_posts() ) : $rsliderQuery->the_post();  
    
                                                // Meta
                                                $post_link = get_permalink();
                                                $post_cats  =  wp_get_post_categories( $post->ID );
                                                $get_post_tags = get_the_tags( $post->ID );
                                                $print_post_tags = array();
    
                                                if ($get_post_tags && count($get_post_tags) > 0) {
                                                    $get_post_tags = array_slice($get_post_tags, 0, 3);
    
                                                    foreach ($get_post_tags as $oneTag) {
                                                        $tag_link = get_tag_link($oneTag->term_id);
                                                        $print_post_tags[] = '<a href="'. $tag_link .'">'.$oneTag->name.'</a>';
                                                    }
                                                    $print_post_tags = implode(", ", $print_post_tags);
                                                }
    
                                                if ($post_cats && count($post_cats) > 0) {
                                                    $post_cat  =  $post_cats[0];
                                                    $post_cat_name = get_cat_name( $post_cat );
                                                    $post_cat_link = get_category_link( $post_cat );
                                                } else {
                                                    $post_cat_name = null;
                                                    $post_cat_link = null;
                                                }
    
                                                $post_time    =  get_the_date('F j, Y');
                                                $post_format  =  get_post_format( $post->ID );
                                                $post_views   =  dankov_get_post_views( $post->ID );
    
                                                if (!$post_format) {
                                                    $post_format = 'Post';
                                                    $icon_type = null;
                                                } else {
                                                    $icon_type = $post_format;
                                                }
    
                                                switch ($icon_type) {
                                                    case 'standard':
                                                        $postIco = 'pencil';
                                                        break;
                                                    case 'quote':
                                                        $postIco = 'speech';
                                                        break;
                                                    case 'gallery':
                                                        $postIco = 'picture';
                                                        break;
                                                    case 'camera':
                                                        $postIco = 'image';
                                                        break;
                                                    case 'film':
                                                        $postIco = 'video';
                                                        break;
                                                    case 'audio':
                                                        $postIco = 'music-tone-alt';
                                                        break;
                                                    case 'link':
                                                        $postIco = 'link';
                                                        break;
                                                    default:
                                                        $postIco = 'pencil';
                                                        break;
                                                }
    
                                                // Feat image
                                                if ( has_post_thumbnail() ) {
                                                    $rs_ID = get_post_thumbnail_id( $post->ID );
                                                    $rs_Thumb = wp_get_attachment_image_src( $rs_ID, $rsliderQuery->found_posts == 1 ? 'large' : 'project-medium' );
                                                    $rs_Thumb = $rs_Thumb[0];
                                                    $prevThumb = wp_get_attachment_image_src( $rs_ID, 'thumbnail');
                                                    $prevThumb = $prevThumb[0];
                                                } else {
                                                    $rs_Thumb = get_template_directory_uri() . '/assets/images/placeholder.png';
                                                    $prevThumb = get_template_directory_uri() . '/assets/images/placeholder_sq.png';
                                                }
    
                                                $subtitle = wpautop( do_shortcode( get_the_excerpt() ) );
                                                $excerpt = $subtitle;
                                                $subtitle = implode(' ', array_slice(explode(' ', $subtitle), 0, 5));
    
                                                // Compose thumb
                                                $slideBody =
                                                    '<div class="rsContent" style="display:none;">
                                                        <a class="rsImg" data-rsBigImg="'. esc_url($rs_Thumb) .'" href="'. esc_url($rs_Thumb) .'">
                                                            <div class="rsTmb">
                                                                <div class="rsTmb-small">
                                                                    <img alt="" src="'.esc_url($prevThumb).'" />
                                                                </div>
                                                                <h5>'. esc_html(get_the_title()) .'</h5>
                                                            </div>
                                                        </a>
                                                        <div class="rsABlock sampleBlock" data-delay="0"  data-move-effect="bottom">
                                                            <div class="slider-text">
                                                                <h3><a href="' . $post_link . '">' . esc_html(get_the_title()) . '</a></h3>
    
    																<ul class="rsBlock-meta">'; 
    
                                                                        if ($post_format != 'Post') {
                                                                            $slideBody .= '<li><i class="icon-'. $postIco .'"></i> <span><a href="#" style="text-transform: capitalize;">'. $post_format .'</a></span></li>';
                                                                        }
    
    																	$slideBody .= '<li></li>
    
                                                                    </ul>
                                                                </div>
                                                            </div>
                                                        </div>';
    
                                                echo $slideBody;
    
                                            endwhile;
                                        ?>
    
                                        </div> </div>
    
                                        <script>
                                            jQuery(document).ready(function($) {
                                                var gallery = $('#dankov-video-gallery'),
                                                    gallCont = gallery.find('.rsContent');
                                                gallCont.show();
                                                gallery.royalSlider({
                                                    arrowsNav: false,
                                                    fadeinLoadedSlide: true,
                                                    controlNavigationSpacing: 0,
                                                    controlNavigation: 'thumbnails',
                                                    thumbs: {
                                                        autoCenter: true,
                                                        fitInViewport: true,
                                                        orientation: 'vertical',
                                                        spacing: 0,
                                                        paddingBottom: 0
                                                    },
                                                    transitionType: 'slide',
                                                    keyboardNavEnabled: false,
                                                    imageScaleMode: 'fill',
                                                    imageAlignCenter:true,
                                                    slidesSpacing: 0,
                                                    loop: true,
                                                    loopRewind: true,
                                                    numImagesToPreload: 3,
                                                    video: {
                                                        autoHideArrows:true,
                                                        autoHideControlNav:false,
                                                        autoHideBlocks: true
                                                    },
                                                    autoScaleSlider: false,
                                                    autoScaleSliderWidth: 680,
                                                    autoScaleSliderHeight: 339,
                                                    imgWidth: 595,
                                                    imgHeight: 339,
                                                    autoPlay: {
                                                        enabled: true,
                                                        pauseOnHover: true,
                                                        delay: 5000,
                                                    }
                                                });
    
                                            });
                                        </script>
    
                            <?php endif; } ?>
                        <!-- royal slider -->
    
                                    <?php
                                        $get_cats_for_filter = array(
                                            'type'                     => 'post',
                                            'child_of'                 => 0,
                                            'parent'                   => '',
                                            'orderby'                  => 'name',
                                            'order'                    => 'DESC',
                                            'hide_empty'               => 1,
                                            'hierarchical'             => 0,
                                            'exclude'                  => '',
                                            'include'                  => '3,4',
                                            'number'                   => 2,
                                            'taxonomy'                 => 'category',
                                            'pad_counts'               => false
                                        );
    
                                        $get_cats_for_filter = get_categories($get_cats_for_filter);
                                    ?>
                            <div class="posts" style="margin-top:50px;">
                                <div class="widget-line">
                                    <h3 class="widget-title">Latest Wrestling News:</h3>
                                    <ul class="post-category univermag-post-filter-by-cat">
                                       <?php /*  <li><a href="#" class="active" data-catslug="#all">All</a></li> */ ?>
                                        <?php
                                            foreach ($get_cats_for_filter as $cat => $val) {
                                        ?>
                                     <?php /*      <li><a href="<?php echo get_category_link($get_cats_for_filter[$cat]->term_id); ?>" data-catslug="<?php echo $get_cats_for_filter[$cat]->term_id; ?>"><?php echo $get_cats_for_filter[$cat]->name; ?></a></li>  */ ?>
                                        <?php
                                            }
                                        ?>
                                    </ul>
                                </div>
                                <script>
                                    jQuery(function($) {
                                        "use strict";
    
                                        var cats = $('.univermag-post-filter-by-cat li a'),
                                            post = $('.type-post');
    
                                        cats.click(function(e) {
                                            e.preventDefault();
    
                                            cats.removeClass('active');
                                            $(this).addClass('active');
    
                                            var catSlug     =  $(this).attr('data-catslug'),
                                                postsGroup  =  $('.type-post'),
                                                visCount    =  0;
    
                                                if (catSlug !== '#all') {
                                                    postsGroup.hide();
    
                                                    postsGroup.each(function($ind, $el) {
                                                        var postCats = $($el).attr('data-catslug-post');
    
                                                        if (typeof postCats == 'string') {
                                                            var idsArr = postCats.split(" ");
                                                            for (var i = 0; i < idsArr.length; i++) {
                                                                if (idsArr[i] == catSlug) {
                                                                    $($el).show();
                                                                    visCount = $($el).is(":visible") ? (visCount+1) : visCount;
                                                                }
                                                            };
                                                        }
                                                    });
    
                                                    if (visCount === 0) {
                                                         window.location.href = $(this).attr('href');
                                                    }
    
                                                } else {
                                                    postsGroup.show();
                                                }
    
                                        });
                                    });
                                </script>
    
    <?php
                                            if (have_posts()) :  while (have_posts()) : the_post(); 
    
                                                    get_template_part( 'format', get_post_format() );
    
                                                endwhile;
    
                                            if ( function_exists('wp_pagenavi') ) {?>
    
                                            <?php } else { ?>
    
                                                <div id="but-prev-next"><?php next_posts_link( __( 'Older posts', 'dankov' ) ); previous_posts_link( __( 'Newer posts', 'dankov' ) ); ?></div>
    
                                            <?php }
    
                                            endif;
                                        ?>
    
      <?php
    // Carousel
    wp_reset_query();
    wp_reset_postdata();
    
    global $dankovData;
    
    $add_carousel = isset($dankovData['add_carousel']) ? $dankovData['add_carousel'] : true;
    $qty = isset($dankovData['carousel_qty']) ? $dankovData['carousel_qty'] : 10;
    
    if ($add_carousel) :
    
        $carousel_args = array(
            'tax_query' => array(
                 array(
                     'taxonomy' => 'post_format',
                     'field' => 'slug',
                     'terms' => array(
                         'post-format-audio',
                         'post-format-video'
                     )
                 )
            ),
            'posts_per_page' => $qty
        );
    
        $carousel = new WP_Query($carousel_args);
    
        if ($carousel->have_posts()) :
        ?>
                                <div class="widget-line"><h3 class="widget-title"><?php _e('Recent video & audio', 'dankov') ?>:</h3></div>
    
        <div class="under-slider-block">
                    <div class="slider4">
    <?php
                        while ($carousel->have_posts()) :
                            $carousel->the_post();
    
                            $ID = get_the_id();
                            $title = get_the_title();
                            $thumb = null;
                            $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($ID), 'medium', true );
    
                            if (has_post_thumbnail()) {
                                $thumb = $thumb[0];
                            } else {
                                $thumb = get_template_directory_uri() . '/assets/images/placeholder.png';
                            }
    
                            $thumb = '<img src="'. esc_url($thumb) .'" alt="'. esc_attr($title) .'" />';
    ?>
                        <div class="slide">
        <div <?php post_class('image-slider');?>>
            <a href="<?php the_permalink() ?>" class="video-thumb video"><?php echo $thumb; ?></a>
        </div>
                        </div>
                        <?php endwhile; ?>
        </div>
        </div>
    
        <?php endif; ?>
    <?php endif; // Carousel END ?>
                                    </div><!-- #post -->        
    
                            </div></div>
    
            <?php
                if ($sidebarOff != 'sidebar-two') {
                    echo '<aside class="percent-sidebar ' . $sidebarOff . '">';
                        if(isset($dankovData['blog_sidebar'])) {
                            if($dankovData['blog_sidebar'] !='') {
                                $blog_sidebar_position = $dankovData['blog_sidebar'];
                                dynamic_sidebar($blog_sidebar_position);
                            }
                            else {
                                get_sidebar();
                            }
                        }
                        else {
                            get_sidebar();
                        }
                    echo '</aside>';
                }
            ?>
    
     </div><!-- #content -->
            </div>
    
    <?php get_footer(); ?>

The topic ‘Combine sticky notes with regulars posts’ is closed to new replies.