Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1296276
    Palzme
    Participant

    Hey

    I have created a custom shortcode, by using my functions.php file, but i would like the shortcode really to have the following code to count the published posts:

    <?php echo wp_count_posts()->publish; ?>

    Is there any way to implement this easily as the code for the shortcode only specifies an output which is HTML based?

    function custom_shortcode() {
    $output = ‘HTML BASED OUTPUT’;
    return $output;
    }

    #1296288
    Palzme
    Participant

    Hey guys,

    Just an update- I have managed to work around this now

    I installed the following plugin: https://wordpress.org/plugins/php-code-for-posts/ (created a shortcode with the PHP script embedded and that worked perfectly)

    If there’s any work arounds to integrate this into a child theme that would be awesome, but for now at least i could use the work around 😉

    Kind Regards,
    Jordan

    #1296356
    Rad
    Moderator

    Hi there,

    Thanks for writing in.

    You can add something like this from your functions.php

    function short_code_name() {
    
    $output = 'HTML BASED OUTPUT';
    return $output;
    
    }
    
    add_shortcode('short_code_name', short_code_name);

    Then simply add [short_code_name] to your editor content. You can add many as you want, just as long as the shortcode names are unique.

    Thanks!

  • <script> jQuery(function($){ $("#no-reply-1296276 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>