Welcome Guest, Not a member yet? Register   Sign In
importing articles from wordpress
#1

[eluser]Piatra[/eluser]
i have my domain, lets call it example.com . i have wordpress in one folder and codeigniter in another. i want to import articles from wordpress to codeigniter .
my structure is
www.example.com/blog/
www.example.com/codeigniter/
I tried importing using
Code:
<?php
// Include Wordpress
define('WP_USE_THEMES', false);
require('./blog/wp-load.php');
query_posts('showposts=1');
?>
But i get an error saying call to undefined function query_posts. Really need to get this done. Any help is more then welcomed!
#2

[eluser]CroNiX[/eluser]
I put require('blog/wp-blog-header.php'); in my index.php, then you should be able to run your query and I don't think you need to include wp-load.php.

Just beware that when you include wp you will have certain functions that will be overridden. Like anchor(); will be wordpresses anchor() function because it gets defined first....and you probably don't want to use the built in anchor function because it will prefix all urls with the blog url...

Its best to only include it on the page(s) that will actually use it.
#3

[eluser]Piatra[/eluser]
Now i have another problem. when i include it it doesn't find the file. How should i do it using ../../../blog/wp-blog-header.php or the absolute path www.example.com/blog/wp-blog-header.php ?

Solved the inclusion part but i still get the same error !
#4

[eluser]CroNiX[/eluser]
If you are including it in your index.php, it is relative to that files location, which is usually in the html root dir. I assume your wp install is also in the root dir.

public_html (site root)
-blog (wp folder)
-application (ci folder)
-index.php (ci index.php)

Then you would just
require_once('blog/wp-blog-header.php');
in ci's index.php

EDIT: include should be at the top of the index.php, before CI stuff.
#5

[eluser]danmontgomery[/eluser]
To clarify, no matter where you include it in your CI application, the path should be relative to CI's index.php
#6

[eluser]Piatra[/eluser]
Fatal error: Call to undefined function query_posts() in /home/example/public_html/example.com/codeigniter/application/views/external.php on line 14
im stuck at square one . i include it just fine now but it still doesn;t work
#7

[eluser]CroNiX[/eluser]
is your
Code:
require_once(‘blog/wp-blog-header.php’);
at the TOP of your index.php file?

what if you put
Code:
var_dump(query_posts('showposts=5'));
immediately after the require?




Theme © iAndrew 2016 - Forum software by © MyBB