Running the Loop outside of WordPress

I have a static website and WordPress installed at mywebsite.com/blog.

I have a page on my external static website which displays a list of all posts [per the codex][1] using the following code

div class="container" id="blog-home"     
div class="col-md-8 col-sm-8 col-xs-12"
  ?php
  $args = array( 'numberposts' = 10,    'post_status'="publish",'post_type'="jobs",'orderby'="post_date");
  $postslist = get_posts( $args );
  foreach ($postslist as $post) : setup_postdata($post); ?
     div class="post"
        h3a href="?php the_permalink(); ?" title="?php the_title_attribute(); ?"?php the_title(); ?/a/h3
                p?php the_date(); ?/p
                 p?php the_excerpt(); ?/p
    /div
  ?php endforeach; ? 
/div

I then have tried to create a page which can display a single post with

?php
// Include WordPress
 define('WP_USE_THEMES', false);
  require('/server/path/to/your/wordpress/site/htdocs/blog/wp-blog-header.php');
 query_posts('showposts=1');
?

 div class="col-md-8 col-sm-8 col-xs-12"

    ?php while (have_posts()): the_post(); ?
    h2?php the_title(); ?/h2
    ?php the_excerpt(); ?
    pa href="?php the_permalink(); ?" class="red"Read more.../a/p
    ?php endwhile; ?

/div

The bit I'm missing is getting the Title on the first page (which lists all posts) to link to the right single post.

Basically I'm trying to avoid having to go to the wordpress blog at all but always running the loop outside of WordPress. Is this possible and could anyone help me fill in this gap!?

Cheers

Topic outside-wordpress loop Wordpress

Category Web


You should rewrite the_permalink() function.

http://your_blog_addres/<?php the_slug(); ?>

should be what you are looking for.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.