Preventing Users From Accessing wp-admin

function jeba_blockusers_init() { if ( is_admin() && ! current_user_can( 'administrator' ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { wp_redirect( home_url() ); exit; } add_action( 'init', 'jeba_blockusers_init' ); }...

Remove p tags from shortcode WordPress

If you are a WordPress developer, you should have face this issue. In shortcodes, you sometimes may see the p tag and for this reason you code does not work as you want. I will show you how to fix this and it’s super easy. Just copy the following code snippets...

Insert ads after second paragraph of single post content

He guys! Today I will show you how to modify a post in WordPress so that you can have your ads or some customized contents just after the second paragraph of your WordPress single posts. Just look at the following code snippets and you will find the explanation inside...

First post image auto set as featured image

Sometimes we need to grab the first post image as our WordPress Features Post Image. The following code snippet will save your first post image as your Features Post image. function apbd_auto_featured_image() { global $post; if (!has_post_thumbnail($post->ID)) {...

Create Custom WordPress User Roles

Sometimes we need to add custom user roles in our WordPress CMS. The following code snippets will add a custom user role inside your CMS. For more roles, please see the capabilities from Codex or WordPress documentary. This is just an example to start it right away....

Remove Query Strings from Static Resources

When it comes to WordPress performance, this question comes up quite a bit, and that is how to remove query strings from static resources. Your CSS and JavaScript files usually have the file version on the end of their URLs, such as domain.com/style.css?ver=4.6. Some...