PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Counter

  1. Tobe
    Member

    Hi Chris,

    You created a lovely code to create a counter see : http://pastebin.com/NSsVZgt8

    If I am correct this is a function to create a shortcode.
    I would like to have that counter in my header (header.php) and (shortcodes don't work there)

    As far as I understand I need to add the function in function.php of my theme, and some other line of PHP in my header.php.

    Can you please share an altered code to be used in the header.php?

    Thanks in advance!

    Tobe

    Posted 11 years ago on Tuesday March 19, 2013 | Permalink
  2. David Peralty

    You can run shortcodes outside of the WordPress loop/body by using PHP. Read their documentation about that here: http://codex.wordpress.org/Function_Reference/do_shortcode

    Posted 11 years ago on Tuesday March 19, 2013 | Permalink
  3. Tobe
    Member

    Hi David,
    Thank you for pointing out to that link. Shortcodes look easy when I use WYSIWYG, but as for coding it is confusing me. I just start to have some understanding in php, but addind/creating shortcodes is still not clear for me. For example, I checked the examples in the link you provided, and it just don't make sense to me. (yeah I am such a nooby)

    Is there a way to just add another function, (not to a create shortcode) and an php get command (to call that function) which can be added in the header?

    Posted 11 years ago on Wednesday March 20, 2013 | Permalink
  4. David Peralty

    The way I'm showing you is the same as what you are looking for, but you can still use the shortcode function that Chris created without any modification. So you add that to your functions.php file. So you have the function that will do the work.

    Next you want to add a PHP call in the header file, which would be the second example used on the link I sent you.

    So in your header.php file you would have:

    <?php echo do_shortcode('[donations form=37]'); ?>

    That would be the PHP "get" you are looking for.

    Posted 11 years ago on Wednesday March 20, 2013 | Permalink
  5. Tobe
    Member

    Hi David,

    Thank you that helped me a lot. You made my day :-)

    Posted 11 years ago on Wednesday March 20, 2013 | Permalink

This topic has been resolved and has been closed to new replies.