Support » Plugin: Nelio Featured Posts » Showing specific featured posts

  • Resolved SonalM

    (@sonalm)


    Hi, is there any way to generate only specific posts, e.g. if I only wanted to display the 1st or 3rd featured post (instead of all of them), how would I do that? On one page I need all the featured posts but on another I only need the content for specific posts, I am using the_widget() to call the widget.

    https://wordpress.org/plugins/nelio-featured-posts/

Viewing 1 replies (of 1 total)
  • Plugin Author David Aguilera

    (@davilera)

    Hi SonalM!

    Thanks for using our plugin 🙂 I’m sorry I couldn’t reply you before.

    I’ve updated the plugin and added a new filter (neliofp_get_featured_posts). You can use this filter to select which posts are shown under which pages as follows (add the code in your theme’s functions.php file):

    add_filter( 'neliofp_get_featured_posts', 'prefix_filter_posts' );
    function prefix_filter_posts( $feat_posts ) {
    
      if ( is_page() || is_single() ) {
        switch ( get_the_ID() ) {
    
          case 2: // The landing page, whose ID is 2
            $feat_posts = array( $feat_posts[0], $feat_posts[3] );
            break;
    
          case 27: // A certain post (ID 27)
            $feat_posts = array( $feat_posts[2] );
            break;
    
          // Add as many cases as required.
    
        }
      }
    
      return $feat_posts;
    }

    I hope this helps you! Please, don’t forget to add your review on our plugin.

Viewing 1 replies (of 1 total)
  • The topic ‘Showing specific featured posts’ is closed to new replies.