Last active
December 15, 2015 17:09
-
-
Save TravisBallard/5294137 to your computer and use it in GitHub Desktop.
Adding custom more link to template tags in TB-Testimonials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'tbt_template_functions', 'add_tags_to_tbt' ); | |
/** | |
* add custom template tags to tbtestimonials plugin | |
* | |
* @param mixed $t - twig instance | |
*/ | |
function add_tags_to_tbt( $t ) | |
{ | |
$t->addGlobal( 'page_link', call_user_func( 'tbt_testimonial_page_link' ) ); | |
} | |
/** | |
* return link to testimonials page | |
* | |
*/ | |
function tbt_testimonial_page_link() | |
{ | |
if( $page = get_page_by_title( 'testimonials' ) ){ | |
return sprintf( ' <a href="%s#testimonial-%d">Read More</a>', get_permalink( $page->ID ), get_the_ID() ); | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment