Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 !

share|improve this question
    
Wouldn't an iframe (loading a page template) solve your problem? –  brasofilo Apr 9 '12 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 Apr 9 '12 at 9:27
    
Then you'd probably make a direct MySQL query without invoking WP functions... –  brasofilo Apr 9 '12 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 Apr 9 '12 at 14:06
    
Thanks for the snippet, it'll be usefull. –  Baptiste Apr 9 '12 at 16:36
add comment

1 Answer

up vote 1 down vote accepted

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: http://stackoverflow.com/questions/3490740/pulling-images-from-rss-atom-feeds-using-magpie-rss There are lots of other resources via Google.

share|improve this answer
    
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 Apr 9 '12 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. –  songdogtech Apr 9 '12 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 Apr 9 '12 at 16:36
    
Yes, try what brasofilo offered. –  songdogtech Apr 9 '12 at 17:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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