php - Post url is not coming in anchor href tag -


my code

$args=array( 'post_type' => "product", 'post_status' => 'publish', 'taxonomy'   => 'products_category', 'order' =>'asc', 'number'     => '', 'hide_empty'  => 0 );  $my_query = new wp_query( $args ); echo '<ul class="product_category">';     if( $my_query->have_posts() ) {         while ($my_query->have_posts()) : $my_query->the_post();              echo '<li>';             echo '<a href='. the_permalink() .'>';             echo the_title();             echo '</a></li>';         endwhile;     }  echo '</ul>';wp_reset_query(); 

i want show posts of product post type. posts coming correctly, link of post not coming inside href tag.

instead of using the_permalink() use get_permalink();

$args=array( 'post_type' => "product", 'post_status' => 'publish', 'taxonomy'   => 'products_category', 'order' =>'asc', 'number'     => '', 'hide_empty'  => 0 );  $my_query = new wp_query( $args ); echo '<ul class="product_category">';     if( $my_query->have_posts() ) {         while ($my_query->have_posts()) : $my_query->the_post();              echo '<li>';             echo '<a href='. get_permalink() .'>';             the_title();             echo '</a></li>';         endwhile;     }  echo '</ul>';wp_reset_query(); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -