Ask your WordPress questions! Pay money and get answers fast! (more info)

Trigger plugin shortcode from the template WordPress


Hello, we use here the Job Roller Theme and I have this plugin installed:

This plugin creates a shortcode:

[ptp size="" type="d"]Linktitel[/ptp]

This I would like to link to a job details page below instead of the print function.

The point I have already found and localized:


<li class="print"><a href="./?print"><?php _e('Print Job','appthemes'); ?></a></li>

Here's the link.

My question is what do I have to write to drive the short code with the link and if we are in the process where I can I find the printer icon image would gladly trade for a PDF icon

Answers (3)


Bob answers:

can you please explain what exactly you want to do?

do you want <a> tag in <li> have a link to download pdf file?

you can specify you link following way with static id of your post.

<li class="print"><a href="<?php echo get_bloginfo('url'); ?>/wp-content/plugins/codecanyon-3408117-word-press-office/ptp_stamp.php?id=4690&parentid=&ptp_type=d"><?php _e('Print Job','appthemes'); ?></a></li>

<strong>Notice "id=4690" in above code. it is id of</strong>

you can change it and set it dynamically.

<?php global $post; ?>
<li class="print"><a href="<?php echo get_bloginfo('url'); ?>/wp-content/plugins/codecanyon-3408117-word-press-office/ptp_stamp.php?id=<?php echo $post->ID; ?>&parentid=&ptp_type=d"><?php _e('Print Job','appthemes'); ?></a></li>

or if you are inside loop then you can try.

<li class="print"><a href="<?php echo get_bloginfo('url'); ?>/wp-content/plugins/codecanyon-3408117-word-press-office/ptp_stamp.php?id=<?php the_ID(); ?>&parentid=&ptp_type=d"><?php _e('Print Job','appthemes'); ?></a></li>

dold comments:

works perfectly! Thanks for the help

Bob comments:

i am glad to hear that it works. :)


Dbranes answers:

I don't fully understand what you are trying to do ;-)

In general you trigger the shortcode with <em>do_shortcode( $text )</em>, so you can try this:

<?php echo do_shortcode( '[ptp size="" type="d"]Linktitel[/ptp]' ); ?>

So it sounds like you want:

<li class="print"><a href=""><?php echo do_shortcode( '[ptp size="" type="d"]Linktitel[/ptp]' ); ?></a></li>

but I don't think you will need the link, so you can try:

<li class="print"><?php echo do_shortcode( '[ptp size="" type="d"]Linktitel[/ptp]' ); ?></li>

where you can modify the shortcode to your needs.

Hope this helps.


To add a pdf logo you will need to add this to your style.css

.section_footer li.pdf {
background: url(images/pdf.png) no-repeat scroll 10px 22px;

to match the <em><li class="pdf">...</li></em> in part. Your <em>pdf.png</em> image should be 16x16 pixels.


We don't want to modify the plugin itself, so we can try different methods of overwriting it.


<em>a)</em> Let's first try this:

<li class="pdf"><a href="" class="pdf"><?php echo str_ireplace( 'ptp_btn', 'ptp_btn_pdf', do_shortcode( '[ptp size="" type="d"]Linktitel[/ptp]' ) ); ?></a></li>

to see if we can replace the button class, to get rid of the default style.

<em>b)</em> If part a) works, we should then add this script (slightly modified from the original one) to the page (footer):


Save this script to the file <em>/wp-content/themes/jobroller/js/ptp_pdf.js</em> and enqueue it via

add_action( 'wp_enqueue_scripts', function(){
wp_enqueue_script( 'ptp-pdf-script', get_stylesheet_directory_uri() . '/js/ptp_pdf.js', array( 'jquery' ), '1.0', TRUE );

<strong>2)</strong> We could also take another twist on this and instead add the following code snippet to your <em>functions.php</em> file in the current theme directory:

add_action('wp_print_styles', function(){
wp_dequeue_style( "ptp_btn_style" );
},99 );

to remove the <em>ptp_btn.css</em> file from the page.

To target the page template <em>single-job_listing.php</em> you could try:

add_action('wp_print_styles', function(){
is_page_template( 'single-job_listing.php' ) && wp_dequeue_style( "ptp_btn_style" );
},99 );

Let me know if method 1 or 2 works for you.

dold comments:

Thank you very much
okay. in principle it funktinoert. but of course he takes the button from the plugin. do you have a idea how to fix it that the css of the page accesses.

Dbranes comments:

ok great, we can then fix the layout, I will check it out.

dold comments:

ok. Thx

Dbranes comments:

Let me know if method 1 or 2 works for you - see updated answer.

dold comments:

ok i have now only 1) ​​made​​. It looks the same but no longer works. is an error in the code?

dold comments:

sorry only have 1 a) made​​. to which agency should I place it in the footer?

div class="clear"></div>

</div><!-- end inner -->

</div><!-- end content -->

<?php appthemes_before_footer(); ?>

<div id="footer">

<div class="inner">

<p><?php _e('Copyright &copy;','appthemes'); ?> <?php echo date_i18n('Y'); ?> <?php bloginfo('name'); ?>. <a href="/impressum">Impressum</a></p>

</div><!-- end inner -->

</div><!-- end footer -->

<?php appthemes_after_footer(); ?>

</div><!-- end wrapper -->

<?php wp_footer(); ?>

<?php appthemes_after(); ?>



Dbranes comments:

For part 1.b you first create the file <em>/wp-content/themes/jobroller/js/ptp_pdf.js</em> and then open the file /wp-content/themes/jobroller/functions.php and add the code above to enqueue the script file.

ps: Later you can create your own plugin with these modifications ;-)

dold comments:

Not so good :)

Parse error: syntax error, unexpected T_FUNCTION in /wordpress/wp-content/themes/jobroller/functions.php on line 38

dold comments:

is this right :

Dbranes comments:

can you post the code you pasted into functions.php?

dold comments:

add_action( 'wp_enqueue_scripts', function(){

wp_enqueue_script( 'ptp-pdf-script', get_stylesheet_directory_uri() . '/js/ptp_pdf.js', array( 'jquery' ), '1.0', TRUE );


Dbranes comments:

hmm, I guess you have PHP < 5.3.

Try this instead:

add_action( 'wp_enqueue_scripts', 'wpq_enqueue_scripts' );

function wpq_enqueue_scripts()
wp_enqueue_script( 'ptp-pdf-script', get_stylesheet_directory_uri() . '/js/ptp_pdf.js', array( 'jquery' ), '1.0', TRUE );

dold comments:

Parse error: syntax error, unexpected $end in /kunden/232667_88046/webseiten/ on line 48

Dbranes comments:

weird, but watch out for extra lines when you copy/paste from this site:

Try this instead:

dold comments:

ok no more error message. But still not working: (

Dbranes comments:

good, you still have to create


the file with the corresponding script .

dold comments:

I've already created. however agrees not your mortgage entirely. it is here:


Dbranes comments:

The file must be web accessible

For example:

What's the current url to the file you created?

dold comments:

in this folder is the file

dold comments:

in this folder is the file:


Dbranes comments:

aha, you have places it inside <em>/wp-content/themes/jobroller/includes/js/</em> directory:


wp_enqueue_script( 'ptp-pdf-script', get_stylesheet_directory_uri() . '/js/ptp_pdf.js', array( 'jquery' ), '1.0', TRUE );


wp_enqueue_script( 'ptp-pdf-script', get_stylesheet_directory_uri() . '/includes/js/ptp_pdf.js', array( 'jquery' ), '1.0', TRUE );

I see your <em>ptp_pdf.js</em> file contains some extra html stuff, replace it with this:

since it can be tricky to copy code from this site ;-)


Arnav Joy answers:

I think in this page

you want the job like "Leider konnte nichts gefunden werden" to be linked to its details page like

so you have to use <?php the_permalink();?> function , where ever you are getting following :-

<h1><?php the_title();?></h1>

you have to replace it with

<h1><a href="<?php the_permalink();?>"><?php the_title();?></a></h1>