Reputation: 303
Edit:The problem is the script timeout.
Up to WordPress version 3.2.1 I used this code on a page called 'list.php' in the root of my site. When I go to this page, permalinks to all the posts I posted on my site show up.
Once I installed WordPress 3.5.1 this code stopped working. How could we fix it?
<?php
require_once('wp-config.php');
require_once('wp-includes/wp-db.php');
global $post;
$myposts = get_posts('numberposts=-1&offset=1');
foreach($myposts as $post){
echo trim(the_permalink())."<br>";
}
?>
Upvotes: 0
Views: 254
Reputation: 5067
Did you tried using WP_Query
and the call of wp-load.php
at the beginning of your php file? The code will look like this:
<?php
header('Content-Type: text/html; charset: UTF-8');
require( '../../../../wp-load.php' );
$my_query = new WP_Query('numberposts=-1&offset=1');
if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post();
echo trim(the_permalink())."<br>";
endwhile;
endif;
?>
Where ../../....../
is the path to your wp-load.php
file.
Upvotes: 1