WordPress custom excerpt length

Posted by Prem Tiwari | Updated on | WordPress


Use the below example code in your theme‚Äôs functions.php file for WordPress custom excerpt length. Limit the length of the displayed excerpt by writing in the theme: excerpt(’20’); Example: This will limit the excerpt to …

Remove Private and Protected Prefix

Posted by Prem Tiwari | Updated on | WordPress


This function removes the “Privite:” prefix from posts and pages marked private. Useful for content only visible to logged in users or groups.

Grab all custom fields globally

Posted by Prem Tiwari | Updated on | WordPress


Use the below example code in your theme’s functions.php file to grab all custom fields globally: Then call the field with a single line:

Remove XML-RPC when not in use for performance boost

Posted by Prem Tiwari | Updated on | WordPress


WordPress uses a CURL operation to test for SSL capability for XML-RPC. If you’re using XML-RPC but not using, then you can remove the filter. This is a small performance boost (since basically WP does …

Return the number of comments

Posted by Prem Tiwari | Updated on | WordPress


Use the below example code in your theme’s functions.php file to return the number of comments. This is like count_user_posts(), but returns the number of comments instead: More: Count User’s posts (including custom post types) …

Enable oEmbed in Text/HTML Widgets

Posted by Prem Tiwari | Updated on | WordPress


Use the below example code in your theme’s functions.php file to enable oEmbed in Text/HTML Widgets:

Only show posts and media of the logged-in Author & fix the post/media counts on the filter bars.

Posted by Prem Tiwari | Updated on | WordPress


By default, WordPress allows Authors to see the titles of other users posts, unpublished drafts, and all media, even though they cannot be edited. Use this code to only allow posts and media of the …

Add page template filter to page listing

Posted by Prem Tiwari | Updated on | WordPress


Adds a page template filter to the page listing, so you can view a list of pages that have a given template attached. Requires at least 3.1 to work, though the meta_query could be replaced …

Add a “Settings” link for plugins on the plugin list page

Posted by Prem Tiwari | Updated on | WordPress


Set “Settings” link for plugins on plugin-page in WordPress backend, easy to use jump to settings for users (the code is also with an solution for WordPress version smaller 2.9)

Extending Auto Logout Period

Posted by Prem Tiwari | Updated on | WordPress


Using the code below you can increase the time cookies are kept and therefor users who are logged in remain logged in longer:

Collection of quick function.php edits

Posted by Prem Tiwari | Updated on | WordPress


I have a few awesome tweaks in functions.php as well. Found most of these by searching for them over the years. Excerpt Ending Replace WP Admin Logo Custom Favicon WP-Admin Custom Admin Footer

Remove Auto Linking of URLs in WordPress Comments

Posted by Prem Tiwari | Updated on | WordPress


Use the following example code to remove Auto Linking of URLs in WordPress Comments:

Fixed: Remove Default WordPress Meta Boxes

Posted by Prem Tiwari | Updated on | WordPress


Use the following example code to remove Default WordPress Meta Boxes:

Remove Author Metabox/Options & Move to Publish MetaBox

Posted by Prem Tiwari | Updated on | WordPress


One of the things that drive me crazy is a cluttered WordPress Admin area. One of the elements which I now always setup from the start in my functions.php file is removing the Author MetaBox …

Quickly Determine Server & Environment Details

Posted by Prem Tiwari | Updated on | WordPress


If you have multiple servers and multiple environments such as development, QA, and production environments, this can be very useful. For my systems, environment is determined by the first 3 letters of the hostname, but …