Change Custom Post Type slug in WordPress

Posted by Prem Tiwari | Updated on | WordPress


Change Custom Post Type slug in WordPress. The register_post_type_args filter can be used to modify post type arguments:

Where does WordPress store version number?

Posted by Prem Tiwari | Updated on | WordPress


If you need to get the wordpress version in your script, there is a global variable: $wp_version (right now it’s something like ‘3.1-RC3-17376’) It contains the wordpress version. If you need to acquire if from a file, …

WordPress get all posts in RSS

Posted by Prem Tiwari | Updated on | WordPress


WordPress get all posts in RSS. Codex has example snippet on how to use post_limits filter to override amount set in admin for feed.

Add class to before_widget from within a custom widget

Posted by Prem Tiwari | Updated on | WordPress


Aha, so the $before_widget variable is a string representing div element: <div class=”widget my” id=”my-widget-1″> . So I checked the $before_widget for the “class” sub-string and added my $widget_width value to it. The code is from my custom widget file: I wanted to …

Exclude Current Post from Recent Posts Loop

Posted by Prem Tiwari | Updated on | WordPress


This the post__not_in arg should work dandy for you:

How can i limit the character length in excerpt?

Posted by Prem Tiwari | Updated on | WordPress


How can i limit the character length in excerpt. Add the below lines in your current activated theme’s function.php file.

Four reasons why every business needs a website and how to do it yourself without hiring a web agency or freelancer.

Posted by Prem Tiwari | Updated on | in WordPress.


If your business has come this far without a website, you may be wondering: Do I really need a website for my business? What’s the benefit of having a website if my business is already …

PHP array_chunk() example

Posted by Prem Tiwari | Updated on | in PHP Documentation.


PHP array_chunk() — Split an array into chunks. Chunks an array into arrays with size elements. The last chunk may contain less than size elements. Syntax: Returns a multidimensional numerically indexed array, starting with zero, …

PHP array_shift() example

Posted by Prem Tiwari | Updated on | in PHP Documentation.


array_shift — Shift an element off the beginning of array. array_shift() shifts the first value of the array off and returns it, shortening the array by one element and moving everything down. All numerical array …

PHP array_unshift() example

Posted by Prem Tiwari | Updated on | in PHP Documentation.


array_unshift — Prepend one or more elements to the beginning of an array. array_unshift() prepends passed elements to the front of the array. Note that the list of elements is prepended as a whole, so …

How to control accept encoding on HTTP API requests?

Posted by Prem Tiwari | Updated on | WordPress


Quite an edge case, but the accepted encoding types should be filterable nonetheless. I can see a few situations where fine, granular control over this header would be useful (as in adding an API that …

Open a Thickbox with content trough AJAX

Posted by Prem Tiwari | Updated on | WordPress


The second parameter for tb_show is the URL, so you’ll want to use something like..

How does WordPress handle permalinks?

Posted by Prem Tiwari | Updated on | WordPress


The redirect_canonical function in /wp-includes/canonical.php is called on any given URL and will attempt to best-guess the URL the user wanted, and redirect them to there, when a URL does not exist. It has a …

Custom post type with a forced fixed aspect ratio image crop

Posted by Prem Tiwari | Updated on | WordPress


You will have to add support for thumbnails in your functions.php/plugin-file.php From here you can modify this output in your loop to work for your needs:

Generate Thumbnails only for Featured Images

Posted by Prem Tiwari | Updated on | WordPress


This function will generate an image by temporarily registering an image size, generating the image (if necessary) and the removing the size so new images will not be created in that size.