SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    May 2010
    Posts
    229
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    wp_query function with links

    on this site i'm using the following code to pull in the 2 most recent posts in the middle footer widget.

    PHP Code:
    <?php
    $custom_query 
    = new WP_Query'posts_per_page=2&cat=1' );
    if ( 
    $custom_query->have_posts() ) : while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?>

    <p id="title"><?php the_title(); ?></p>
    <p id="small-date">Posted on: <?php the_time('F j, Y'?></p>
    <?php the_excerpt(); ?>
    <hr /> 
    <?php endwhile; else : ?>

    <h3>Sorry...</h3>
    <p>No posts were found.</p>
      
    <?php endif; ?>
    please advise how I make it so that the Post Titles link to the actual posts, just like the Continue Reading links to. Thanks in advance!

  2. #2
    SitePoint Addict
    Join Date
    May 2010
    Posts
    229
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    i figured it out. just needed this:

    <p id="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •