Category Archives: Uncategorized

How to use WordPress shortcodes in themes-/templates – WP-Snippet.com How to use WordPress shortcodes in themes-/templates – WP-Snippet.com

This snippet will allow you to insert WordPress shortcodes into your theme-/templates – using WordPress built-in function do_shortcode() Instructions Add this code your theme files where you want the shortcode content to be run. Tested with WordPress v. 4.9.5 Last Modified: 21.05.2017 Last Reviewed: 21.05.2017 How to use WordPress shortcodes in themes-/templates 4.4 (87.88%) 33 … Continue reading How to use WordPress shortcodes in themes-/templates – WP-Snippet.com How to use WordPress shortcodes in themes-/templates – WP-Snippet.com

How to change the WordPress default excerpt length – WP-Snippet.com How to change the WordPress default excerpt length – WP-Snippet.com

This snippet will let you define a new custom default excerpt length for the WordPress excerpts output. The following example will set the default excerpt length to 20 characters. Instructions Add this code to your functions.php file. function new_excerpt_length($length) { return 20; } add_filter(‘excerpt_length’, ‘new_excerpt_length’); function new_excerpt_length($length) {      return 20; } add_filter(‘excerpt_length’, ‘new_excerpt_length’); Tested … Continue reading How to change the WordPress default excerpt length – WP-Snippet.com How to change the WordPress default excerpt length – WP-Snippet.com

How to include specific custom post types in WordPress search results – WP-Snippet.com How to include specific custom post types in WordPress search results – WP-Snippet.com

Custom post types are not included in the WordPress search results by default – adding this snippet to you functions.php creates a function that allows specific custom post types to be queried and searched by WordPress. Instructions Add this to your functions.php file add_filter( ‘pre_get_posts’, ‘custom_post_type_search’ ); function custom_post_type_search( $query ) { if ($query->is_search) { … Continue reading How to include specific custom post types in WordPress search results – WP-Snippet.com How to include specific custom post types in WordPress search results – WP-Snippet.com

How to Disable the WordPress JSON REST API without plugin – WP-Snippet.com How to Disable the WordPress JSON REST API without plugin – WP-Snippet.com

The WordPress JSON REST API can be useful for developers building apps using WordPress. Other site owners may find it unusable – and it could also potentially expose your website to DDoS attacks that can be resource intensive, hence slowing down the site. The following code snippet will render the WordPress REST API disabled by … Continue reading How to Disable the WordPress JSON REST API without plugin – WP-Snippet.com How to Disable the WordPress JSON REST API without plugin – WP-Snippet.com

WordPress Code Snippets – WP-Snippet.com WordPress Code Snippets – WP-Snippet.com

This snippet allows you to show the current local time in the local language the WordPress installation has been configured to use. Learn how to restrict WordPress media library access to user’s own uploads. This WordPress snippet will allow you to show the image caption for the featured image in your WordPress posts without using … Continue reading WordPress Code Snippets – WP-Snippet.com WordPress Code Snippets – WP-Snippet.com

How to display content for mobile- or desktop only using WordPress “wp_is_mobile”. – WP-Snippet.com How to display content for mobile- or desktop only using WordPress “wp_is_mobile”. – WP-Snippet.com

Did you know that you can use WordPress built-in “mobile detect” function wp_is_mobile to create a simple shortcode that can hide certain parts of your content from mobile visitors and-/or desktop visitors. The wp_is_mobile function returns true when your site is viewed from a mobile browser. Using this function you can create adaptive-/responsive wordpress themes … Continue reading How to display content for mobile- or desktop only using WordPress “wp_is_mobile”. – WP-Snippet.com How to display content for mobile- or desktop only using WordPress “wp_is_mobile”. – WP-Snippet.com

Show a list of WordPress post by a specific user – WP-Snippet.com Show a list of WordPress post by a specific user – WP-Snippet.com

This WordPress snippet will let you show a list of post by a specific user. This is useful if you for example want to show a list of posts from a specific user on Custom Post Types etc. Instructions 1. Add a Custom Field (read more about WordPress Custom Fields) to the Page or Custom … Continue reading Show a list of WordPress post by a specific user – WP-Snippet.com Show a list of WordPress post by a specific user – WP-Snippet.com