0 1 2 3 4 5 6 7 8 9 10 11 12 13 | function pdf_button_filter( $content ) { $pre_content = $post_content = '<a class="pdf-button btn" href="javascript:pdf_url=location.href;location.href=\'http://pdfmyurl.com?s=l&url=\'+escape(pdf_url)">A pdf button!</a>'; $content = $pre_content . $content . $post_content; return $content; } function add_pdf_button_content(){//whatever template condition you want here //if(is_single())//for just posts //if(is_page())//for just pages if(is_singular( 'park' ))// park is the custom post type add_filter('the_content', 'pdf_button_filter', 1); } add_action('template_redirect', 'add_pdf_button_content'); |