Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1346878

    Hello Support Team,

    if I use the content element “Blog posts” and display them in the grid layout, the posts marked with “Keep post on top” are not kept on top. This only works in the list views.

    Is there a solution for this?

    Many greetings
    Stephan

    #1347084

    Hey Stephan,
    Thank you for your patience and for pointing this out, I have reported this to the Dev Team and will reply when I hear back from them.

    Best regards,
    Mike

    #1347191

    can you try this in your child-theme functions.php:

    
    function sticky_posts_first($query, $params) {
    
      $include = array();
      $sticky = get_option( 'sticky_posts' );
    
      $args = array(
      'post__not_in' => $sticky,
      'orderby' => 'title',   // here you can influence the orderby option of the non sticky post to your needs 
      'order'	=> 'asc',    //  the order of the non sticky posts
      'numberposts' => -1  	 // -1 for all - that number is for the non sticky posts  
      );
      $posts = get_posts( $args );
    
      foreach($posts as $post) {
      $include[] = $post->ID;
      }
      if ( !is_sticky() ) {
        $include = array_merge($sticky, $include);
      };
    
      $query['post__in'] = $include;
      $query['orderby'] = 'post__in';
    
    return $query;
    }
    add_filter('avia_post_slide_query','sticky_posts_first', 10, 2);

    but that is only for the enfold blog posts ALB

    PS for those params you can have:
    orderby: ‘title’, ‘rand’, ‘date’, ‘author’, ‘name’, ‘modified’, ‘comment_count’, ‘menu_order’
    order: ‘ASC’, ‘DESC’

    #1347381

    Hello Guenni007,
    thank you very much, the workaround works great:
    https://www.staufeneckschule.de/
    However, the settings for sorting are generally overwritten, but I can live with that, since they are supposed to be in descending order everywhere anyway.
    Many greetings
    Stephen

    #1347482

    that part:

    $args = array(
      'post__not_in' => $sticky,
      'orderby' => 'title',   // here you can influence the orderby option of the non sticky post to your needs 
      'order'	=> 'asc',    //  the order of the non sticky posts
      'numberposts' => -1  	 // -1 for all - that number is for the non sticky posts  
      );

    is only for the non sticky posts – and changing the orderby to: ‘title’, ‘rand’, ‘date’, ‘author’, ‘name’, ‘modified’, ‘comment_count’ or ‘menu_order’
    does not work ?

    #1347483

    btw: hier gibt es übrigens eine kleine Abwandlung wenn die Sachen paginiert werden:
    https://kriesi.at/support/topic/sticky-posts-not-displaying-forst/#post-1230187

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.