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
Post a Comment