CodeIgniter Forums
Wordpress data into website based on CodeIgniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Wordpress data into website based on CodeIgniter (/showthread.php?tid=56266)



Wordpress data into website based on CodeIgniter - El Forum - 12-06-2012

[eluser]Leo78[/eluser]
Hey,

I have a website based on CodeIgniter and external WordPress blog (but the website and the blog are hosted in the same database).
In my website I would like to display some recent posts, favorite posts and etc (the meaning is just take data from the WordPress blog).

There is a WordPress library for CodeIgniter? or should I need to build a library from scratch and simply retrieve data from the database manually without using the API of the WordPress? Is it good idea to build a library (or at the other words: API for my needs)?

Thank you very much.

EDIT: oops, I published at the wrong forum, please move this topic to 'Development & Programming'.


Wordpress data into website based on CodeIgniter - El Forum - 12-06-2012

[eluser]pickupman[/eluser]
Since they are hosted in the same database, you should write a simple model that get posts/pages from the database. You can load the Wordpress bootstrapper, and access the native functions like get_posts(), but probably not worth the overhead. Another option is to use a JSON plugin. That allows simple access to call a url and get a json string of posts. Then parse the JSON. I have used both methods, the latter when they are in different databases. Either option, you can cache the results to speed up the page.