CONSTRUCTOR : PHP allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.
DESTRUCTORS : PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as all references to a particular object are removed or when the object is explicitly destroyed or in any order in shutdown sequence.
Category: PHP
How to Remove/Disable RSS feeds from WordPress?
Easy way to Remove/Disable RSS feeds from WordPress is install and activate “Remove RSS Feed” plugin.
No need to set anything. This plugin will remove/disable the RSS feeds from WordPress when you activate.
Please let me know, If you have any queries or feedback.
How to hide/change WordPress login URL without plugin?
By default, wp-login.php file having all the codes to generate login page. There are 5 steps to hide/change WordPress login URL without plugin.
- Create a new file.
- Copy the code from your wp-login.php, then paste it into your new file.
- Replace each instance of wp-login.php with the new file name. Find and replace is your friend.
- Delete the wp-login.php file.
- Login through your new URL.
Please let me know, If you have any queries or feedback.
How to get count of users having each role, as well as the count of all users?
By default WordPress having an function called count_users() to get count of users having each role, as well as the count of all users.
Check below example code for your reference.
$result = count_users(); echo 'There are ', $result['total_users'], ' total users'; foreach($result['avail_roles'] as $role => $count) echo ', ', $count, ' are ', $role, 's'; echo '.';
Please feel free to contact me if you need any further information.
How to disable email notification after password change?
To disable email notification after password change, Add the following code in your theme file or plugin files.
/* To disable email notification after password change */ add_filter( 'send_password_change_email', '__return_false' );
Please feel free to contact me if you need any further information.
How to get category ID from category name in WordPress?
By default WordPress having an function called get_cat_ID() to retrieve get category ID from category name. Please check the below sample code for how to get category ID from category name in WordPress. Replace ‘Category Name’ with your category name.
$categoryID = get_cat_ID('Category Name');
If you have any doubt, Please comment here.
How to get list of all sites in WordPress Multisite Network?
We can retrieve list of all sites in WordPress Multisite Network by using get_sites() function.
This function will return the data in array format. Please check the sample code below.
$sites = get_sites(); var_dump($sites);
If you have any doubt, Please comment here.
How to get list of available themes with data in WordPress?
We can retrieve list of themes with theme data by using wp_get_themes() function.
This function will return the data in array. Please check the sample code below.
$themes = wp_get_themes(); var_dump($themes);
If you have any doubt, Please comment here.
How to get count of posts in a particular category?
You can get get count of posts in a particular category by using below code. Before use please replace “CUSTOM_POST_TYPE” and “CUSTOM_TAXONOMY” with your post type and taxonomy.
$the_query = new WP_Query( array( 'post_type' => 'CUSTOM_POST_TYPE', 'tax_query' => array( array( 'taxonomy' => 'CUSTOM_TAXONOMY', 'field' => 'id', 'terms' => TERM_ID ) ) ) ); $count = $the_query->found_posts;
Have any doubt please comment here.
How to get the count of posts in an WordPress archive page?
If you want to get the count of posts in wordpress archive page, You can by 2 ways.
First option is
$count = $GLOBALS['wp_query']->post_count;
Another option is
$count = $GLOBALS['wp_query']->found_posts;
Have any doubt please comment here.