![]() |
Wordpress integration - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Wordpress integration (/showthread.php?tid=69973) |
Wordpress integration - Luca4k4 - 02-05-2018 Hi, i've searched, but i find only similar posts that don't solve my problem. I've a website in Codeigniter. Now, i want to add some page made with wordpress, for example a homepage and a contact page (i'd like to use wordpress because these pages will be make by my collegues that know perfectly wordpress). How can i have some page in CI and others in WP ? For example, i need: http://mysitename.com => show WP homepage http://mysitename.com/animals/cat => call "cat" function of "animals" controller in CI http://mysitename.com/contact => show WP contact page I tried to follow this guide: https://www.cometchat.com/blog/how-to-integrate-codeigniter-with-wordpress/ But this didn't resolve the problem. Infact, to show WP homepage i've to go in the WP subdirectory.. something like: http://mysitename.com/wordpress and i want avoid to show subdirectory in url. Thank you in advace and sorry if my english is not so good RE: Wordpress integration - skunkbad - 02-05-2018 I've tried a few ways to merge the two applications in the past. My opinion is that the best way to handle the merge is just to use mod_rewrite in an .htaccess file to "pre-route" to each application. Whichever application would handle more requests is the default, and for the other application you simply rewrite to a different front controller. So if you're WordPress app uses index.php, then the CI app uses ci_index.php. RE: Wordpress integration - Luca4k4 - 02-05-2018 Hi, thank you for the answer To do this, should i have wordpress and codeigniter in the same directory? because the .htaccess redirect changes the url and the only way to avoid this is to have all in the same directory RE: Wordpress integration - skunkbad - 02-05-2018 Yes. If you look at WP it has wp-content, wp-admin, wp-includes, while CI has application, system. That being the case, there's really no reason why these two apps can't live together in the same directory. RE: Wordpress integration - Luca4k4 - 02-06-2018 I will try this solution, thank you a lot! ![]() RE: Wordpress integration - gabrielcastillo - 02-09-2018 One thing you can try is using the WordPress REST API. This allows you get WordPress REST API data objects that can be interfaced with other applications. So, you can pull your homepage data via WordPress REST API and display on your codeigniter home page.. You can also do this with other Pagea as well.. When loading your view pass the WP JSON object and render inside your codeigniter view page. Here is a link to the WordPress REST API RE: Wordpress integration - skunkbad - 02-09-2018 (02-09-2018, 03:30 PM)gabrielcastillo Wrote: One thing you can try is using the WordPress REST API. This allows you get WordPress REST API data objects that can be interfaced with other applications. That's kind of an awkward way to get data, when you have full access to the database. Why not just use CI to query the WP database directly? I do it all the time. Example method: PHP Code: /** RE: Wordpress integration - gabrielcastillo - 02-09-2018 (02-09-2018, 06:04 PM)skunkbad Wrote:(02-09-2018, 03:30 PM)gabrielcastillo Wrote: One thing you can try is using the WordPress REST API. This allows you get WordPress REST API data objects that can be interfaced with other applications. Of course that will work.. But to keep things simple, you could use Code: /wp-json/wp/v2/pages?slug=home-page to get all the data into your view template and parse the object however you want. No need to create another model if not needed. My example is just a quick solution to the problem above. RE: Wordpress integration - antonioalcala - 03-01-2018 Your Wordpress level is very high. Good job!!! Thanks!!! RE: Wordpress integration - botikol123 - 05-19-2021 Hi sir, I would like to ask about the integrating thing using wp-json, should the wp and CI database should be one or can be done seperately? I am new and I run a site with CI script and love to create a posts using wp. |