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
Code Snippets
How to change the WordPress breadcrumbs Home link in StudioPress Genesis
If you have breadcrumbs enabled in your StudioPress Genesis theme, you may want to change the WordPress breadcrumbs Home link. Just add this WordPress Code Snippet to the functions.php file in your current WordPress theme in order to change the breadcrumbs home link.
[Read more…] about How to change the WordPress breadcrumbs Home link in StudioPress Genesis
How to customize the default Search Form text in StudioPress Genesis Framework themes
Just add this WordPress Code Snippet to the functions.php file in your current WordPress theme in order to customize the Search Form text in StudioPress Genesis Framework themes.
[Read more…] about How to customize the default Search Form text in StudioPress Genesis Framework themes
How to change WooCommerce product page image size in WordPress
If you are using WooCommerce for an online store plugin for your WordPress site, you may want to change the size of the product image shown on product page. Just add this WordPress Code Snippet to your CSS stylesheet in your current WordPress theme in order to change the width of the product page product image in WooCommerce.
/** * Change Product Image width on WooCommerce Product Pages * * @author WPSnacks.com * @link https://www.wpsnacks.com */ .single .images { width: 30%!important; }
Just change the width I listed above with whatever width you want your WooCommerce product page product image to be.
How to enter WordPress Maintenance Mode
Your site may need maintenance from time to time to keep it running smoothly. It is a good idea to keep your site unavailable to visitors while you are doing this maintenance. Just add this WordPress Code Snippet to the functions.php file in your current WordPress theme in order to easily enter WordPress Maintenance Mode.
[Read more…] about How to enter WordPress Maintenance Mode
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
How to add custom widget areas to StudioPress Genesis Framework themes
Just add this WordPress Code Snippet to the functions.php file in your current WordPress theme in order to add custom widget areas to your StudioPress Genesis Framework theme.
[Read more…] about How to add custom widget areas to StudioPress Genesis Framework themes
How to exclude a category from the loop on your home page
Just add this WordPress Code Snippet to the functions.php file in your current WordPress theme in order to exclude one or more categories from the loop on your home page.
[Read more…] about How to exclude a category from the loop on your home page
How to center text, div, or other element using CSS in WordPress
If you are using WordPress for your website, you may want to center a div or other element or item on your website. Just add this WordPress Code Snippet to your CSS stylesheet in your current WordPress theme in order to center a div or other item in WordPress.
/** * Center element * * @author WPSnacks.com * @link https://www.wpsnacks.com */ #yourdivname { text-align: center; }
Just replace #yourdivname with whatever element, either a id(#) or class(.) that you want to have it’s interior elements centered. Hope this helps with your WordPress problem, enjoy.