Forrest
Forrest

Reputation: 607

Static wordpress page linking to posts

Hi I am trying to making my static wordpress page seen here

Link to the posts that are shown. However they are just linking to the file directory in the browser and not the post.

It was working before where it would just link to the post in a wordpress theme but now that doesn't even work.

I haven't touch the code in a week I left it in the state as mentioned above, where it would link but just to the wordpress theme.

Here is the code I use to get the information to the static page from wordpress -

<?php
  // set up or arguments for our custom query
  $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
  $query_args = array(
    'post_type' => 'post',
    'paged' => $paged
  );
  // create a new instance of WP_Query
  $the_query = new WP_Query( $query_args );
?>

<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); // run the loop ?>
  <article>
    <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

    <div class="entry">
        <?php the_content(); ?>
    </div>
      <small><?php the_time('F jS, Y'); ?> by <?php the_author_posts_link(); ?></small>
      <hr>
  </article>
 <?php endwhile; ?>


<?php if ($the_query->max_num_pages > 1) { // check if the max number of pages is greater than 1  ?>
  <nav class="prev-next-posts">
    <div class="prev-posts-link">
      <?php echo get_next_posts_link( 'Older Entries', $the_query->max_num_pages ); // display older posts link ?>
    </div>
    <div class="next-posts-link">
      <?php echo get_previous_posts_link( 'Newer Entries' ); // display newer posts link ?>
    </div>
  </nav>
<?php } ?>

<?php else: ?>
  <article>
    <h1>Sorry...</h1>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
  </article>
<?php endif; ?>

Basically what I am trying to do is get it so when I click on the post it takes me to that post. Not to the file directory.

Any help is appreciated. Thank you.

I'm using xubuntu 16.04_LTS incase that has anything to do with compatibility in wordpress.

I have permalinks setup as shown

enter image description here

Upvotes: 0

Views: 482

Answers (3)

Forrest
Forrest

Reputation: 607

I seem to have fixed the issue I have been having. Thanks for all the replies.

Incase someone needs to know what I have done.

I went into mysql and dropped the database and recreated it. Must of gotten corrupted somehow.

Upvotes: 0

Johannes
Johannes

Reputation: 67778

try to rename Index.php as index.php. It seems like Wordpress can't find index.php as a template for the post and therefore the system redirects you to the file directory since it can't find any of the possible template files.

Addition: Since your "Index.php" seems not to include code for the display of single posts, you might want to set up a file "single.php" as a template for single posts. But nevertheless, Wordpress will try to use index.php in many situations - always when the actual template file for a particular post type can't be found, like archive.php, page.php and many others...

So it might be a good idea to create a "regular", all-purpose index.php, rename your static page to something else, for example to front-page.php and define t as your starting page.

Upvotes: 1

Tom Woodward
Tom Woodward

Reputation: 1713

If all you want is the links to work . . .

http://auroraservers.org/MainSite/?p=38   ---fails
http://auroraservers.org/MainSite/wordpress/?p=38  ---works

That works and could be adjusted in the permalinks custom area. If you want that URL to be different, you're dealing with htaccess changes.

While not beautiful, you could replace the_permalink(); with

    $id = get_the_ID();
    $url = 'http://auroraservers.org/MainSite/wordpress/?p='.$id;

Upvotes: 1

Related Questions