1

My "Read More" button is linking to the current page page instead of the excerpt page it is suppose to be linking to. Here is my function in function.php file:

function new_excerpt_more($more) {
   global $post;
return ' <a href="'. get_permalink($post->ID) . '"> ...Read More</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');

This is occurring in in excerpts being displayed from a custom walker for wp_list_pages.

0

Global $post variable is filled on by running post through the loop (the_post() method or function, setup_postdata() function). If you look at the source for Walker_Page it is not running a loop and so does not make posts' data available through $post.

Since excerpt_more is not provided with info on the post either, you would need to track post data on your own and access it inside your filter function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.