Shortcodes are very useful to bloggers. You can use them to easily execute functions you have already created, which especially helpful for functions that are repeated often. Just add this WordPress Code Snippet to the functions.php file in your current WordPress theme in order to make custom Shortcodes in WordPress.
[Read more…] about How to make custom Shortcodes in WordPress
Code Snippets
How to change default Speak Your Mind comment text in StudioPress Genesis
If you are using the StudioPress Genesis Theme Framework for your WordPress site, you may want to change the default comment text that says “Speak Your Mind” when you first install your Genesis Framework theme. Just add this WordPress Code Snippet to the functions.php file in your current WordPress theme in order to change the default “Speak Your Mind” text in your comments section.
[Read more…] about How to change default Speak Your Mind comment text in StudioPress Genesis
How to create a shortcode to display the WordPress site url
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 url 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 links and other text that may have displayed the url. You can use a shortcode to find the current site url and display it based on the url the WordPress theme is currently installed on, so no matter where the theme is used, it will display the correct url, which means you won’t have to change it if you move the theme to a new url. 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 url.
[Read more…] about How to create a shortcode to display the WordPress site url
How to hide product sort by dropdown in WooCommerce in WordPress
If you are using WooCommerce for an online store on your WordPress site, you may want to hide the product dropdown sort by box shown on your Shop page and other product archive pages. Just add this WordPress Code Snippet to your CSS stylesheet in your current WordPress theme in order to hide the sort by drop down in WooCommerce.
/** * Hide WooCommerce Product Sort by dropdown * * @author WPSnacks.com * @link https://www.wpsnacks.com */ .archive .woocommerce-ordering { display: none; }
That’s it, now the product sort by dropdown should be hidden from your product archive pages. Hope this helps, enjoy.
How to get custom field value using a shortcode
Just add this WordPress Code Snippet below to the functions.php file in your current WordPress theme to allow you to get custom field values by simply using a shortcode.
[Read more…] about How to get custom field value using a shortcode
How to allow shortcodes to work in Contact Form 7 in WordPress
Contact Form 7 is a great plugin to make custom contact forms on your WordPress site. If you are using shortcodes in your WordPress site, you may want to make it so they will work in the Contact Form 7 plugin’s contact forms. Just add this WordPress Code Snippet to the functions.php file in your current WordPress theme in order to make it so your shortcodes will work when placed in Contact Form 7 plugin’s contact form.
[Read more…] about How to allow shortcodes to work in Contact Form 7 in WordPress
How to hide remove reviews tab on WooCommerce Product Page
If you are using WooCommerce for an online store plugin for your WordPress site, you may want to hide or remove the reviews tab on the WooCommerce Product Page. Just add this WordPress Code Snippet to your CSS stylesheet in your current WordPress theme in order to hide the reviews tab on product pages in WooCommerce.
/** * Remove/Hide WooCommerce Product Page reviews tab * * @author WPSnacks.com * @link https://www.wpsnacks.com */ .single .woocommerce-tabs ul.tabs li.reviews_tab { display: none; }
Hope this helps with your WordPress problem, enjoy.
How to right align text/items in div/other element using CSS in WordPress
If you are using WordPress for your website, you may want to right align 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 right align a div or other item in WordPress.
/** * Right align element * * @author WPSnacks.com * @link https://www.wpsnacks.com */ #yourdivname { text-align: right; }
Just replace #yourdivname with whatever element, either a id(#) or class(.) that you want to have it’s interior elements right aligned. Hope this helps with your WordPress problem, enjoy.
How to change width of Contact Form 7 textarea fields in WordPress
If you are using the Contact Form 7 plugin for WordPress for your contact forms, you may want to change the width of the textarea entry fields. Just add this WordPress Code Snippet to your CSS stylesheet in your current WordPress theme in order to change the width of the textarea entry fields in Contact Form 7 forms.
/** * Change Contact Form 7 textarea width * * @author WPSnacks.com * @link https://www.wpsnacks.com */ .wpcf7-form .wpcf7-form-control-wrap textarea.wpcf7-form-control { width: 250px; }
Just change the width I listed above with whatever width you want your textarea entry fields in Contact Form 7 forms to be. That’s it, now the width of your textarea fields should be changed. Hope this helps, enjoy.
How to hide remove WooCommerce Product Page tabs in WordPress
If you are using WooCommerce for an online store plugin for your WordPress site, you may want to hide or remove the description and reviews tabs on the WooCommerce Product Page. Just add this WordPress Code Snippet to your CSS stylesheet in your current WordPress theme in order to hide the description and reviews tabs on product pages in WooCommerce.
/** * Remove/Hide WooCommerce Product Page tabs * * @author WPSnacks.com * @link https://www.wpsnacks.com */ .single .woocommerce-tabs ul.tabs { display: none; }
Hope this helps with your WordPress problem, enjoy.