Support » Plugin: CleanPrint » Shortcode doesn't work

  • I followed the instructions by adding the code to my template file:

    <?php add_shortcode('cleanprint_print_button', 'get_cleanprint_print_button');
        function get_cleanprint_print_button() {
           if( function_exists('cleanprint_add_print_button') ){
              return cleanprint_add_print_button();
           }
        }
    ?>

    and the shortcode to the page I want the buttons on:

    [cleanprint_print_button]

    but the page just shows the shortcode as it appears in the editor, no buttons. The buttons appear if I active ALL PAGES to have the buttons, but I only want 1 page to have the buttons.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author johncadams

    (@johncadams)

    If added to functions.php file you should not need to wrap the code in a php header, (<?php … ?>) the functions.php file usually has already declared it.

    Also make sure you are running WP 2.5 or later.

    As you can see above, it is wrapped in a php header. But why would I add it to functions.php? I didn’t see that in the documentation anywhere. I added the code to the template within the loop, right above the_content, like this:

    <?php add_shortcode('cleanprint_print_button', 'get_cleanprint_print_button');
        function get_cleanprint_print_button() {
           if( function_exists('cleanprint_add_print_button') ){
              return cleanprint_add_print_button();
           }
        }
    ?>
    
    <?php the_content(); ?>

    I thought that’s what you were supposed to do, I didn’t see any documentation about it. If I added it to the functions file, then where would that button go? I need to place it where I want it, not on all pages, only on the 1 page, so that’s why I added it to the template file I created for this page.

    Running 3.4.2…

    Plugin Author johncadams

    (@johncadams)

    Normally the functions.php file starts the php syntax (look at the top of the file) and never closes it. Therefore you don’t add the php delimiters and simply append the code to the bottom.

    I just didn’t realize the code was supposed to be in the functions file. Do you know how to show a print button only on a specific template?

    Plugin Author johncadams

    (@johncadams)

    I suppose if you moved the code to the template file (without <?php ) that is included by functions.php that may work (give it a try). This is really a general shortcode question and nothing specific to CleanPrint.

    Plugin Author johncadams

    (@johncadams)

    BTW this topic isn’t a review and should move to the support forum.

    Yea I know right! That was really weird, when I clicked on a rating, it automatically took me to that page and I didn’t realize it was a Reviews tab (was really late), so just started typing out my question. I apologize, I don’t know how to move it though. Maybe it can be deleted? I checked here, and there’s no option to delete a review once it’s posted (that I can see).

    Anyway, I already tried the template php. Normally that works, but that’s why I posted the question, because it’s not working.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Shortcode doesn't work’ is closed to new replies.