Fix for get_the_excerpt having the wrong Read More links
-
Hi all,
Been googling around a bit and can’t find a solution, so wondering if anyone has the answer here. A few people seem to have this problem, but nobody’s posted a fix that I can see here, on StackOverflow, or elsewhere.
I have a shortcode plugin which displays a table of objects (kindof like a product list). The code gets a wp_query ($plant_lists) from a selection of posts in a custom taxonomy, and then loops through building the table, as follows:
$plant_lists = new WP_Query(array( 'order' => 'ASC', 'orderby' => 'title', // menu_order ID 'plant_list_category' => $cat, 'post_type' => 'plant_lists', 'post_status' => null, 'nopaging' => 1, 'posts_per_page' => -10) ); $plant_shortcode .= '<table class="planttable"><tbody>'; while($plant_lists->have_posts()): $plant_lists->the_post(); $countPlants++; $family=get_post_meta( get_the_ID(), '_plant_lists_family', true ); $theimage=wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()) , 'plant-image'); $plant_shortcode .= '<tr><td align="center"><a href="' . get_permalink() . '"><img src="'.$theimage[0].'" alt="" /></a></td>'; $plant_shortcode .= '<td><div class="plant-title"><a href="' . get_permalink() . '">'. get_the_title().'</a></div>'; $plant_shortcode .= '<div class="plant-excerpt">'; if($family != NULL){ $plant_shortcode .= '<p><b>Family: '.$family.'</b></p>'; } $plant_shortcode .= '<p>'. get_the_excerpt().'</p>'; $plant_shortcode .= '</div></td></tr>'; endwhile; // end slideshow loop $plant_shortcode .= '</tbody></table>'; if ($countPlants == '0') { $plant_shortcode = 'No plants are currently posted in this category'; } wp_reset_query();
The problem I’m having is that the ‘Continue Reading’ link for each excerpt links to the current page, rather than the page for the post/document. I can’t see any reason that this would happen, and no matter what I try I can’t fix it.
The page in question is here: https://www.pumpkinbeth.com/plants/
Anyone got any ideas?
- The topic ‘Fix for get_the_excerpt having the wrong Read More links’ is closed to new replies.