All Questions (5,617 questions)



Exclude Current Post from Recent Posts Loop

Posted by Prem Tiwari | Updated on

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

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

How to control accept encoding on HTTP API requests?

Posted by Prem Tiwari | Updated on

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

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

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

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

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.

How to conditionally enqueue a stylesheet only for a certain page?

Posted by Prem Tiwari | Updated on

I copy pasted your code into my dev environment, changed nothing but the page name, and it works just fine. Are you sure that it’s not being enqueued and you just have it pointed wrong …

current_shortcode() detect currently used shortcode

Posted by Prem Tiwari | Updated on

current_shortcode() detect currently used shortcode. I made my catch all handler accept a third argument, which is the shortcode name:

How can I display a menu on certain pages only?

Posted by Prem Tiwari | Updated on

That’s a nice option, but I agree with sri, right now it really depends on your theme. You can do a work-around through is_page(). You need to write something like this on your page.php theme …

Is there any action hook for validating a custom field before publishing the post?

Posted by Prem Tiwari | Updated on

At the beginning of wp_insert_post, the function that saves/updates a post, there is a filter called wp_insert_post_empty_content. By default this filter checks whether the title, editor, and excerpt fields are all empty, in which case the save …

Use template_include with custom post types

Posted by Prem Tiwari | Updated on

I am not sure if this will work for you but it is worth a shot. I use this all the time for my custom post types when they require a special template.

Allow user to select a theme to install when they signup

Posted by Prem Tiwari | Updated on

If still relevant, maybe this could help others looking for similar solutions

How to implement WordPress plugin update that modifies the database?

Posted by Prem Tiwari | Updated on

You should be familiar with already, as you should be using it to create the table. On your install hook you should have something like:

Adding Widget form fields dynamically

Posted by Prem Tiwari | Updated on

This is an example of a dynamic widget that renders two fields (image-id and url). if you enter an image-id and press “update”, two new fields are added. I build it to create a slick …