 at work this week there was discussion on how to accomplish something in expressionengine we wanted to pull in entries that were in one category but if there were no entries then pull in from other categories and display that instead we were kind of stumped as to how to do that im not sure if we were missing some easy way to do that but we couldnt think of a nice way to accomplish it lets backup i guess it will be helpful to give you some more context we had created a channel our term for weblog for events you could categorize the events and they would publish in different places in this instance the homepage we wanted to pull an event from one category but if there were none then just display an event from another category the initial code this code was separated out in an embed so that we could use it in various places on the site assign variable channel name= embed channel assign variable category id= embed category exp weblog entries weblog= channel name category= category id show future entries= yes show expired= no limit= 1 disable=a oecategory fields custom fields member data pagination trackbacksa h2 title h2 if events feature image p class= rightside a href= url title path= embed template path img src= events feature image alt= a p if if events summary events summary if pa href= url title path= embed template path class= more read more raquo a p exp weblog entries the code doesnt really need to be explained its not the important part of this post so on the homepage we had code that looked like this to pull in the event embed= site events channel= events category= 7 template path= news events events now what we really wanted to be able to do was to modify the exp weblog entries code to pull from a different category if there were no results something like this exp weblog entries weblog= channel name category= category id show future entries= yes show expired= no limit= 1 disable=a oecategory fields custom fields member data pagination trackbacksa hellip if no results code to pull from a different category if hellip exp weblog entries but the problem was there really was no code that we could put in there that would pull from another category since you cant nest exp weblog entries tags so thats when i remembered that you could stick an embed file in there that could have the exp weblog entries tag inside of it then we realized that the code we wanted to write would be exactly like the code in the embed file we were already working with so we did a little investigation and found out that according to the documentation see notes section you cannot embed an embed within itself that makes sense because you could create an infinite loop but what if we knew that it would not return an infinite loop modified code so we determined that what we could do is not pass in the category on the embed statement and that would pull back any events exp weblog entries weblog= channel name category= category id show future entries= yes show expired= no limit= 1 disable=a oecategory fields custom fields member data pagination trackbacksa hellip if no results embed= site events channel= events template path= news events events if hellip exp weblog entries see how there is no category parameter this time here is the full modified code assign variable channel name= embed channel assign variable category id= embed category exp weblog entries weblog= channel name category= category id show future entries= yes show expired= no limit= 1 disable=a oecategory fields custom fields member data pagination trackbacksa h2 title h2 if events feature image p class= rightside a href= url title path= embed template path img src= events feature image alt= a p if if events summary events summary if pa href= url title path= embed template path class= more read more raquo a p strong if no results embed= site events channel= events template path= news events events if strong exp weblog entries and that worked houston we still have a problem but we then realized that the same problem would occur if there were no future events in any categories so we still needed to go back and solve that problem by similarly passing the value for the show expired parameter in the embed statement as well i left that to my colleague so i didnt test this code but this is my guess of how to solve that problem assign variable channel name= embed channel assign variable category id= embed category strong assign variable show expired= embed show expired strong exp weblog entries weblog= channel name category= category id show future entries= yes strongshow expired= show expired strong limit= 1 disable=a oecategory fields custom fields member data pagination trackbacksa h2 title h2 if events feature image p class= rightside a href= url title path= embed template path img src= events feature image alt= a p if if events summary events summary if pa href= url title path= embed template path class= more read more raquo a p if no results embed= site events channel= events strongshow expired= yes strong template path= news events events if exp weblog entries conclusion was there some really easy way to do this that we completely blanked on it seemed a little hacky but the solution worked 