Limiting the number of promoted articles that display on the home page

6 Comments

  • Diziana

    Hi Stacey,

     

    Just add the below js code to your code editor. 

     

    $(document).ready(function () {

      if(typeof $('.promoted-articles ul').get(0) != 'undefined') {
        var _sectionArticles = $('.promoted-articles ul');
        _sectionArticles.each(function(_aidx, _aitm) {
          var _itmCount = $(_aitm).find('li').length;
          var _allLink  = $(_aitm).prev('h3').find('a').attr('href');
          if(_itmCount > 5) {
            for(var x = (_itmCount - 1); x > 4; x--) {
              $($(_aitm).find('li')[x]).remove();
            }
          }
        });
      }

    });

     

    This will restrict to 5 articles .

    Now in order to restrict the no. of articles to display of your choice set   (_itmCount ) and  x  to be n and n-1 i.e if you want to show 3 then replace 5 with 3 and 4 with 2.

    Hope this will solve your query.

    Happy Customizing. :)

    Cheers,

    Diziana

     

     

     

    -1
  • StaceyPotts

    Thank you! That worked great!

    0
  • Joe Fedric

    Excellent solution!  

     

    ~Joe

    0
  • Diziana

    Cheers Joe!

     

    Diziana

    0
  • Ian Maison

    Hey,

    How would I go about reducing recent-activity but on the Homepage? I've tried the code above with the obvious changes but it does not work.

    Any assistance welcomed.

    0
  • Vladan Jovic
    Community Moderator

    Hey Ian, I see a long time has passed, but here is a code in case you want to show just 3 items:

    ul.recent-activity-list>li:nth-child(n+4) {
    display: none;
    }

    Just paste it at the end of your theme CSS file.

    0

Please sign in to leave a comment.

Powered by Zendesk