WordPress and buddypress programming

Bloginfo Shortcode

Viewing 0 reply threads
  • Author
    Posts
    • #645
      michael mc
      Keymaster
      @michael

      The bloginfo() function in WordPress gives you access to lots of useful information about your site. See the complete list. To access all these values from inside Page/Post content itself, we can make a shortcode to return the values. Add this to your functions.php file in your theme:

      CodeSelect
      function digwp_bloginfo_shortcode( $atts ) {
         extract(shortcode_atts(array(
             'key' => '',
         ), $atts));
         return get_bloginfo($key);
      }
      add_shortcode('bloginfo', 'digwp_bloginfo_shortcode');

      Now you can output any of the values by calling that shortcode with “key”. For example, the name of your site:

      [bloginfo key=’name’]
      Or directly to images in your theme folder:

      [bloginfo key='name'] logo

Viewing 0 reply threads
  • You must be logged in to reply to this topic.