Sometimes, while developing or customizing a WordPress theme or template files, it can be very useful to be able to execute a shortcode inside a template page instead of only within your WordPress Post or Page content. Just add this code below anywhere in your theme’s template pages to execute your shortcode using the do_shortcode() WordPress function:
[Read more…] about How to use shortcodes in your WordPress theme template files
Shortcodes
How to create a shortcode to display the WordPress theme path
Shortcodes are a very useful tool when using WordPress. There are often things you may do a lot and using a shortcode helps make it so you can use one instead of retyping a lot of content. Also, if you are a web developer, you may be creating WordPress themes/sites on a development server that will later be transferred to a client’s server. When doing this, the theme path during development may not be the same as will be after it is transferred over to the client’s live site and server. This can cause extra work after making the transfer editing image paths and other text that may have displayed the theme path. You can use a shortcode to find the current WordPress theme’s stylesheet directory and display that path, so no matter where the theme is used, it will display the correct path, which means you won’t have to change it if you move the theme to a new location. I use this often when developing themes for clients so that when I put an image inside the themes image folder during development, when the theme is later placed on the client’s server, the image path still works without me having to change it. Just add this WordPress Code Snippet to the functions.php file in your current WordPress theme in order to create a shortcode to display the WordPress site’s current theme’s path.
[Read more…] about How to create a shortcode to display the WordPress theme path
How to display a Facebook Share button in WordPress using a shortcode
Just add this WordPress Code Snippet to the functions.php file in your current WordPress theme in order to display a Facebook Share button using a shortcode.
[Read more…] about How to display a Facebook Share button in WordPress using a shortcode