WordPress loop: Display if posts exist

You can use the has_tag function in a conditional statement to achieve what you want. Take a look at the codex page here: Function Reference/has tag. This isn’t 100% tailored to your specific question, but you should see how it’s working and adjust for your specific task: <?php if( has_tag() ) { ?> <?php query_posts( … Read more

Use Loop or direct database query?

In general I try to avoid custom SQL queries as much as i can and use the native WordPress functions but in some cases its much better/faster to use custom queries. if the case is just get a list of posts the you can use the WP_Query or get_posts which will work almost as fast … Read more

Loop output for custom plugin [solution found]

The Solution to my problem is to simply let my plugins output run through the do_shortcode()-Function of WordPress as pointed out by this article: Using Shortcodes Everywhere I updated my plugin so it uses shortcodes, too, so now my output looks like this: // Add this upon plugin initialization add_shortcode( ‘dosomethingawesome’, array( &$this, ‘output_callback’) ); … Read more

The Loop for my theme with static front page is not working

Just before the snippet i posted i was doing something like $posts = array();, it seems that wordpress keeps the collection of the posts to be used on the loop in a variable of the same name, so i was meesing with the data, just changed $posts for $items and now works fine.