Wordpress integration |
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-in...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
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.
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
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.
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 (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: /**
(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.
Your Wordpress level is very high. Good job!!! Thanks!!!
Programador Web - Consultor SEO - antonioalcala.com
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.
|
Welcome Guest, Not a member yet? Register Sign In |