0

I need to know how can I limit those post labels in blogger. I have searched out for it and could not find anything related to limiting post labels. This is what I have achieved so far.

NOTE: I want to show limited post labels under each post title. Like

if(post_label.count() < 3) { //show post label }

So, I need to show 3 labels under each post's title.


<div class='post-category'> 
    <span class='post-label'>
        <b:if cond='data:post.labels'>
            <b:loop values='data:post.labels' var='label'>
                <a expr:href='data:label.url + &quot;?&amp;max-results=10&quot;' rel='tag'>
                    <data:label.name/>
                </a>
                <b:if cond='data:label.isLast != &quot;true&quot;'> 
                </b:if>
            </b:loop>
        </b:if>
    </span> 
</div>
metior
  • 365
  • 1
  • 4
  • 16
  • Unclear... Where does this code supposed to go ? I happen to be a blogger user, but I just can't understand what you are asking for. Elaborate, or I'm sure this will get closed. – kebs May 12 '14 at 09:15
  • I want to show labels under the post title. My question was how can I limit the number of post labels like if (post_label < 3) {}. Meaning show only 3 or less then 3 labels per post – metior May 12 '14 at 09:17
  • I suggest you edit your question instead of giving details in the comments. – kebs May 12 '14 at 09:18

3 Answers3

1

You can only do it by css, for example we have class "post-cat" :

 <span class="post-cat">
   <b:if cond='data:top.showPostLabels and data:post.labels'>
     <b:loop values='data:post.labels' var='label'>
       <a expr:href='data:label.url + &quot;?&amp;max-results=4&quot;' rel='tag'>
         <data:label.name/>
       </a>
       <b:if cond='not data:label.isLast'/>
     </b:loop>
   </b:if>
 </span>

On css you can do this tip :

.post-cat a{
  display: none;
}

.post-cat a:nth-child(1),
.post-cat a:nth-child(2),
.post-cat a:nth-child(3){
  display: block;
}

I hope this helpful after 2 years ago of your question :)

Uikithemes
  • 65
  • 1
  • 8
0

just replace max-results=3 with max-results=10 and save blogger template.

<a expr:href='data:label.url + &quot;?&amp;max-results=10&quot;' rel='tag'>

you're required to change max-results=10 to limit specific "3" number of posts under each label in blogger.

WPDevotion
  • 378
  • 3
  • 16
0

using <b:eval/> tag it will be like

<b:eval expr="data:post.labels[0].name" />
<b:eval expr="data:post.labels[1].name" />
<b:eval expr="data:post.labels[2].name" />

or simply using this trick

   <b:loop values='data:post.labels' index='i' var='label'>
     <b:if cond='data:i == 1'>
       <a expr:href='data:label.url' rel='tag'><data:label.name/></a>
     </b:if>
   </b:loop>
peter hany
  • 43
  • 1
  • 9