• I am trying to get all the permalinks from my site using the following code:

    include "wp-blog-header.php";
    
    		global $post;
    		global $wpdb;
    
    		$myposts = get_posts('numberposts=-1');
    		foreach($myposts as $post) {
    			setup_postdata($post);
    			$files[] = between(get_permalink(), get_bloginfo('url')."/", '.php').'.php';
    		}
    
    		$file = $files[ rand(0,count($files)-1) ];

    When running this code, I get a Broken Link Page. If I comment this code out (ie the include) then the rest of the script works fine. The script is located in the main directory which is the same directory as wp-blog-header.php is located.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Using WordPress Functions on a Non-WordPress File’ is closed to new replies.