Cannot load post in php file
-
Dear WP community,
I am trying to make a news section for my homepage “index.php”. So I use ajax to load “pages/news.php”‘s content into a news div in index.php. This pages/news.php is supposed to pull out latest posts and format them nicely. The blog is in localhost:81/blog/
When I view localhost:81/pages/news.php, it can display the posts, no errors. But when I run localhost:81/index.php, it said “jquery-2.1.4.min.js:4 GET http://localhost:81/pages/news.php 404 (Not Found)”
If I remove this line in pages/news.php:
include(dirname(__DIR__) . ‘/blog/wp-blog-header.php’)
index.php won’t have error, but of course cannot view the posts.
If I copy the code in pages/news.php to index.php, it works (of course with appropriate including path). I am very confused here, how come using the same code but retrieving news.php content from ajax does not work but news.php itself works?Could someone please advise me what has gone wrong?
Thank you for your time reading.
The blog I need help with is: (visible only to logged in users)
-
Hi. You are in the wrong place.
These forums are only for blogs/sites hosted by WordPress.comWordPress.COM and WordPress.ORG are completely separate and different http://support.wordpress.com/com-vs-org/
And you should ask in the WordPress.org forums.
http://wordpress.org/support -
- The topic ‘Cannot load post in php file’ is closed to new replies.