Horje
Excerpt Issue - linkage - Wordpress Solution
Hi everyone. I am having issues with linking a 'read more' and a 'custom field' button through excerpt option. You can view a sample at the following: http://thehelix.ie/web2011/index.php/whatson/ From this you can see that the plugin [amr events list] has pulled in the buttons to the listing. However the linkage is incorrect - the 'more' button should be linking to the actual post and the 'book now' button should be linking externally [click on a post title to see this button in action]. To get these buttons in place I have added the following to the functions.php file

/** Add More button to listing **/
function excerpt_read_more_link($output) {
 global $post;
 return $output . '<a rel="nofollow" href="'. get_permalink($post->ID) . '"> <img src="http://www.thehelix.ie/web2011/wp-content/themes/EvolveHelix/image/theme/button_more.png" alt="More"></a>';
}
add_filter('the_excerpt', 'excerpt_read_more_link');

/** Add Book Now button to listing **/ 
function excerpt_booking_link($output) {
 global $post;
 return $output . '<a rel="nofollow" href="'. get_post_meta($post->ID, 'Booking', true) . '"> <img src="http://www.thehelix.ie/web2011/wp-content/themes/EvolveHelix/image/theme/booknow.png" alt="Book Now!"></a>';
}
add_filter('the_excerpt', 'excerpt_booking_link');
I have tried numerous changes, plus the author of the plugin say it is not an issue with their plugin [i think there might be a conflict though]. So basically I'm lost! Anyone out there know how to fix this? Thanks The evolve team

Solution - 1

As far as I see for some reason all the posts have the same wrong address, but there is no bug with the get_permalink() function, so my guess is that the: $post->ID is the ID of the page and not of the post. Try to print the $post->ID and to see what it prints, my guess is that it will print the page ID.


Solution - 2

Hi, Is that a page using a page template? Because it is using the same post id for all your added button permalink. If it is a template, you should add your button codes within the template's WordPress Loop and not using add_filter in the functions.php Thanks. Denzel


Solution - 3

Hi, The link cant be viewed..It redirects to a wp admin login page..


Solution - 4

Hi, The site not viewable without login.. :D You should use 'excerpt_more'. the filter should be add_filter('excerpt_more', 'your_function');





Wordpress

Related
HTTP Referrer - Contact Form 7 - Transients API - Wordpress Solution HTTP Referrer - Contact Form 7 - Transients API - Wordpress Solution
How to Hide Buddypress Admin Bar For Everyone Except Admin - Wordpress Solution How to Hide Buddypress Admin Bar For Everyone Except Admin - Wordpress Solution
Add Custom Sidebar to wpfolio - Wordpress Solution Add Custom Sidebar to wpfolio - Wordpress Solution
Background image placement - Wordpress Solution Background image placement - Wordpress Solution
Conditional Statement based on Custom Fields Content - Wordpress Solution Conditional Statement based on Custom Fields Content - Wordpress Solution

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9