All Questions (5,600 questions)



How can you set maximum width for original images?

Posted by Prem Tiwari | Updated on

How can you set maximum width for original images. I was able to solve it using the following code:

How to use wpLink without editor?

Posted by Prem Tiwari | Updated on

There is not ethical way of doing this. But still there is a way to do this. WordPress wrote wpLink script keeping in mind that editor is there but still WordPress handle when editor is …

Symbolic Links on dev box with plugins and stylesheets

Posted by Prem Tiwari | Updated on

Symbolic Links on dev box with plugins and stylesheets. As you can see, the plugin URL is correct except for the real path stuck in the middle. We can filter the function responsible for generating …

How does WordPress handle permalink?

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 …

Is there a is_user_logged_in() for multisite?

Posted by Prem Tiwari | Updated on

Is there a is_user_logged_in() for multisite? The way users work in a multisite scenario is that there is a single pool of users, who are then associated with blogs. So, logged in status is common …

add_role() run only once

Posted by Prem Tiwari | Updated on

add_role() run only once. As for best practice run once, if in a plugin you should use register_activation_hook and for any thing else i use a simple custom made conditional function:

Use REGEXP in WP_Query meta_query key

Posted by Prem Tiwari | Updated on

Use REGEXP in WP_Query meta_query key. Your answer is perfect working in the first array lvl, for example:

Force category choice before creating new post?

Posted by Prem Tiwari | Updated on

I solved this by hooking into post-new.php, and checking for a category_id request parameter. If it does not exist, I display a form with a category dropdown that submits back to this page, and then call exit() so the regular …

Custom Post Type Plugin: Where Do I Put The Template?

Posted by Prem Tiwari | Updated on

You can use the single_template filter to switch out the template. In your callback, see if the theme provided a template for the post type, if it did, do nothing. Alternatively, you can use a …

Filter by one custom field, order by another?

Posted by Prem Tiwari | Updated on

You could use the query to filter the content as you intended by using the ‘meta_query’ with filtering options, and for the order part, just add/modify the following parameters: 1. ‘orderby’ => ‘meta_value’ 2. ‘meta_key’ …

Hide other users’ posts in admin panel

Posted by Prem Tiwari | Updated on

Hide other users’ posts in admin panel. Use the below example code in your functions.php file:

Change the WooCommerce Price Display

Posted by Prem Tiwari | Updated on

Change the WooCommerce Price Display. Let’s say you want to add a label to the end of all of your product prices, such as “per package” (helpful if your products are bundles of something or …

How to make flutter card auto adjust its height depend on content

Posted by Andre Scott | Updated on

I recommend you to use flutter_staggered_grid_view: and to give up to AspectRatio widget. More about tiles here.

flutter firestore pagination using streambuilder

Posted by Andre Scott | Updated on

Take a try with below code:

ancestorInheritedElementForWidgetOfExactType is deprecated

Posted by Prem Tiwari | Updated on

Use context.getElementForInheritedWidgetOfExactType<_BlocProviderInherited<T>>().widget and it should work. As far as benefits go, the documentation basically states the same though someone can correct me but I don’t see any difference. You should be able to get rid of the _typeOf …