To add a new custom user role in WordPress, you typically need to use code. Here’s a basic outline of the process: Create a new custom role: You can use the add_role() function in WordPress to create a new role. This function accepts four parameters: the role name, the display name, capabilities (optional), and the… Continue reading To add new custom role in wordpress
Tag: WP-functions
Use of wp_print_footer_scripts hook in WP
The wp_print_footer_scripts hook in WordPress allows developers to add custom scripts or code to the footer of their website. This is particularly useful for including JavaScript or other functionality that needs to be loaded after the main content of the page. Here’s how you can use the wp_print_footer_scripts hook: Understanding the Hook:The wp_print_footer_scripts action is triggered inside the wp_footer action. It provides no… Continue reading Use of wp_print_footer_scripts hook in WP
How to get the name of the image fetched in WordPress using WP inBulit-function
In WordPress, when you fetch an image, you typically retrieve its metadata, which includes various information about the image, such as its title, alt text, URL, etc. To get the name of the image (assuming you’re working within a WordPress loop or have access to the image data), you can use the following code: <?php… Continue reading How to get the name of the image fetched in WordPress using WP inBulit-function
Use of wp-reset-postdata() in WordPress
In WordPress, wp_reset_postdata() is a function used to reset the global $post variable back to the current post in the main query. It’s commonly used after a custom loop or secondary query using WP_Query to restore the global post data to the main query. When you run a custom query using WP_Query, it changes the… Continue reading Use of wp-reset-postdata() in WordPress
Detect when the reader is in a mobile device – WordPress
In WordPress, wp_is_mobile() is a function that is used to determine whether the current user agent (web browser) is accessing the site using a mobile device. This function checks if the user is browsing the site from a mobile device and returns a boolean value accordingly. Here’s an example of how you might use wp_is_mobile()… Continue reading Detect when the reader is in a mobile device – WordPress
How To Get a List of All Active Plugins Programmatically
To get a list of all active plugins programmatically in WordPress, you can use the WordPress API functions. WordPress provides functions that allow you to retrieve information about active plugins. You can use either the get_option function or the wp_get_active_and_valid_plugins function. Here’s how you can use both methods: Method 1: Using get_option: Using wp_get_active_and_valid_plugins: Both… Continue reading How To Get a List of All Active Plugins Programmatically
Enqueue Bootstrap CDN in WordPress
Make Sure that, you are using the latest Bootstrap version.
Why wp_enqueue_style() not Working?
First step is to ensure you are using the correct path of the CSS file. For the responsive Directory use Example: The second step is to ensure that wp_head() is being called on the page you are displaying. It can be placed in your header template (in between <head></head tags) or on top of archives/post files etc.… Continue reading Why wp_enqueue_style() not Working?
How to enqueue style.css file in WordPress theme
It is best to combine all enqueued scripts and styles into a single function, and then call them using the wp_enqueue_scripts action. add_theme_scripts() → Any name can be used for naming the function get_stylesheet_uri() → This function automatically finds the style.css file in the theme folder and outs its URL.
Blog related WP-functions
Some useful WordPress functions used for Blog Development: get_post_permalink() To get the post link get_permalink($post->ID)To get the corresponding Blog link get_the_post_thumbnail_url(get_the_ID())To get the post thumbnail image URL get_the_title()To get the Title of the Post get_the_excerpt()To get the expert Text