I would like to be able to display my last X wordpress posts in the sidebar of my phpBB3 forums.

Since I can't use WP's functions (because trying to use WP's functions into phpBB3 generates conflicts), I have to use a hand-made php script.

So, my question is, has anyone a custom php script that would enable me to retrieve, from a given wp post ID, it's first image in a given size* ?

  • Knowing that each of my wordpress post may have several images, and that I generate several custom image sizes when adding an image to a post.

  • The size I want is 300x100 and is cropped, so I guess that if i can retrieve the image's filename, I just would have to add -300x100.jpg at the end to get the correct filename.

Cheers !

  • Wouldn't an iframe (loading a page template) solve your problem?
    – brasofilo
    Commented Apr 9, 2012 at 3:52
  • That would be a workaround, but i think it would be better to have the HTML to appear in the source for SEO.
    – Baptiste
    Commented Apr 9, 2012 at 9:27
  • Then you'd probably make a direct MySQL query without invoking WP functions...
    – brasofilo
    Commented Apr 9, 2012 at 13:57
  • I mean, something in this lines: $this->db->get_row(" SELECT guid, post_title, post_content, post_excerpt from wp_posts where post_type='attachment' AND post_mime_type='image/jpeg' AND post_parent='$ID')
    – brasofilo
    Commented Apr 9, 2012 at 14:06

1 Answer 1


Try RSS, like Magpie RSS - PHP RSS Parser or Google Feed API — Google Developers to pull posts without using WP's library.

Google Groups has forum posts on pulling images, and someone at SO found a way to pull images from Magpie: https://stackoverflow.com/questions/3490740/pulling-images-from-rss-atom-feeds-using-magpie-rss There are lots of other resources via Google.

  • That would be a solution, but I'd be tied to my RSS. And my RSS doesn't parse all my categories, which would be a limitation to what I want to achieve. I think what I need is a function to get specific image attachement size given a post ID. Is there such a function somewhere I can use or start from ?
    – Baptiste
    Commented Apr 9, 2012 at 9:29
  • What does this mean?: "And my RSS doesn't parse all my categories." Why is your feed limiting categories? It won't do that by default. If you're not going to include WP, you will have to do a direct and remote database query for image sizes. Use CSS to display the image size you want. Commented Apr 9, 2012 at 12:55
  • Yes it's not a default behaviour, I excluded some categories from my feed. What I'll do is custom SQL query the DB to get the image. Thanks.
    – Baptiste
    Commented Apr 9, 2012 at 16:36
  • Yes, try what brasofilo offered. Commented Apr 9, 2012 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.