How do you extract image and content (& URL) from a WP Blog?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

How do you extract image and content (& URL) from a WP Blog?

Post by simonmlewis »

We are trying to do something we have never attempted - to echo on the top level of a website, some content from it's Wordpress blog.

We want to show the last 3-4 blog posts, it's title, a portion of it's content, when it was published, any category, and the "featured image", along with a URL that goes directly to it's page.

I know the URLs are controlled by it's "permalinks". Can I extract the URL of a Post somehow??
How do I get the URL of the image, that's being used as the featured image?
Finally, the content of a blog is in HTML, so will have <p> tags. But if I take just a portion of it, I'm sure the <p> tag won't have an end, so maybe I need to manually add one at the end of my code anyway.

The title and dates are pretty simple I know. It's the other two parts I am having trouble with.

Thanks
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How do you extract image and content (& URL) from a WP B

Post by Celauran »

Using the blog's RSS feed or maybe XMLRPC would likely be simplest and most portable. Have you tried either of those?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do you extract image and content (& URL) from a WP B

Post by simonmlewis »

Wouldn't have a clue how to do it with either.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply