• Resolved fergieferg

    (@fergieferg)


    Hi all,

    I have a wp_query to list the posts title and excerpt for a subcategory. I want the title to link to its respective post, but unable to figure out how to get the a href working properly in the following code. The link that is being generated from the below code is, /category/sub-category/the_permalink(). Any suggestions please?

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    $args = array( 'posts_per_page' => 10, 'order'=> 'ASC', 'orderby' => 'title', 'category_name' => 'diet-tips', 'paged' => $paged,'post_type' => 'post' );
    $postslist = new WP_Query( $args );
    
     if ( $postslist->have_posts() ) :
            while ( $postslist->have_posts() ) : $postslist->the_post(); 
    
    echo "<div style='border:1px groove gray; margin-bottom:5px;'><h3 class='btposth'><a href='the_permalink()'>";
                     the_title();
                 echo "</a></h3><div class='btpostdiv'>";
                     the_excerpt();
                 echo "</div></div>";
    
    "<br />";
      endwhile;  
    
           next_posts_link( 'Older Entries', $postslist->max_num_pages );
                 previous_posts_link( 'Next Entries ?' );
            wp_reset_postdata();
        endif;
        ?>
    
    <br />
Viewing 2 replies - 1 through 2 (of 2 total)
  • echo "<div style='border:1px groove gray; margin-bottom:5px;'><h3 class='btposth'><a href='" . get_the_permalink() . "'>";

    Thread Starter fergieferg

    (@fergieferg)

    Was really hoping you’d reply Michael, I’ve seen you be of great help on a number of questions. Your code worked, thank you so much! This was such a nuisance to try and figure out.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to incorporate a href in wp_query?’ is closed to new replies.