I use a standard loop in my index.php and that shows all the posts beeing posted. What i'm looking for is a code that only shows the posts that have image(s) in it.
With other words: i only want to show posts that have images in content in my loop.
|
I use a standard loop in my index.php and that shows all the posts beeing posted. What i'm looking for is a code that only shows the posts that have image(s) in it. With other words: i only want to show posts that have images in content in my loop. |
|||
|
|
|
I found and modified a chunk of code found here: http://www.wprecipes.com/wordpress-tip-detect-if-a-post-has-at-least-one-image.
I think this just looks for images entered in the rich text editor - if you want to check for featured images as well you'll likely have to add something. Check out |
|||||||||||||
|
|
I would suggest, that the easiest way to go about this is to create a special category called for example, Then you can create a loop which queries your Depending on your needs you can do this other ways, for example by using either.. Custom fields This allows you to create a custom field meta_key/meta_value which you can use to signify the posts special condition, then you can query posts via meta_key/meta_value.
Custom Meta-Boxes (for advanced customization of your custom fields)
Use a custom post type especially for these types of posts With custom post types, you can create a post type just for your image posts, you might call it something like There might be a plugin out there that helps you achieve similar results too but since I rarely if ever use plugins (unless forced to) I wouldn't know. In any case I think a plugin would be overkill too in this situation. |
||||
|
|