Tutorial :Wordpress hiding Post Div



Question:

I wanted to know how to make it possible that if there is no post i would like to be able to hide the DIV that controls the latest blog post only having them appear when someone post somethign on a blog..

Somewhat like a position in joomla but in this case i am using wordpress


Solution:1

Expanding on ceejyaoz's answer

if(have_posts())  {      //... do HTML in here   }  

If there aren't posts, the HTML, and probably the div you are talking about, won't show up. You can even use an else statement for a custom message if there are no posts.


Solution:2

You can use the have_posts() function to detect whether there are any posts in the loop, and do conditionals based on that.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »