Customize first post differently in json feed


#1

I am trying to customize something in JSON feed. You know some magazin template have widget that shows first post differently in “recent post by label widget”. And how can we make it in json feed. Is there any special condition to customize first post differently ?

For example : first post img will be larger and rest is standart 125px.

Thanks in advance


#2

Could you help me? @Mohammad @technohalf


#3

Did you get your solution to customize your first post


#4

No not yet :frowning:

I still want to learn it


#5

Hi, Maybe my reply is to late, but I just see your question and I just sign up just to give you how you can make first post different then other posts, So firstly we will use if condition using javascript of course! for example maybe you have a variable something like htmlcode += or selekton += or something else, as you have! this is an example to have a differnet first post then other posts :slight_smile:

if  ( i === 0 )  {
  htmlcode +='<li class="post first">Your first post codes was here</li>';
} else {
  htmlcode +='<li class="post">Your other posts codes was here</li>';
}

what if we need to have the same structure for the first post and second post then other posts! This is an example of it :slight_smile:

if ( ( i === 0 ) ||  ( i === 1 ) ) {
  htmlcode +='<li class="post first">Your first post codes was here</li>';
} else {
  htmlcode +='<li class="post">Your other posts codes was here</li>';
}

And now what if we need to have another structure for first post and another structure for second post then other posts! This is an example of it :slight_smile:

if ( i === 0 ) {
  htmlcode +='<li class="post first">Your first post codes was here</li>';
} else if ( i === 1 ) {
  htmlcode +='<li class="post second">Your second post codes was here</li>';
} else {
  htmlcode +='<li class="post">Your other posts codes was here</li>';
} 

So as you see we have an array of entries on json feed like json.feed.entry[i].title, so this code json.feed.entry[0].title is refer to the first post so this is why we use i === 0 and the second post is json.feed.entry[1].title so this is why we use i === 1

the variable i is defined on for loop, for (var i=0; i<json.feed.entry.length; i++). is there is any question I’m here to explain :slight_smile:

Do not forget to follow me on Themeforest - themeforest.net/user/infinyteam/portfolio.


#6

You can see my reply is will help you to know how to do it!