All from category : 'Level 5 : Modify the code'



How to display a nice “[... read more]” message

If you use the standard WorPress distribution, then after the excerpt you see something like this: [...]
There is no link inside the … and there is no “more” word.

I want to change [...] into a clickable [... read more], which will lead to the actual post.

In the /wp-includes/formatting.php file, search for [...] (should be around line 860.
Replace the default line:
array_push($words, ‘[...]‘);
with:
array_push($words, ‘<a href=”‘ . get_permalink() . ‘”>[... read more]</a>’);

Save the file, upload it and you’re done.

How to reset the WordPress administrator’s password?

Step 1: Login to WordPress, as an administrator, using any WRONG password
What script from the WordPress folders checks if you are using the right password for the user “admin”? Let’s find out. Let’s try to login with the wrong password, for instance with the password “ak45mjg385v3543knj6y23″. The login page will display the error message “Incorrect password.”

Now, what file did generate that error message? We search all files from our WordPress folder for the exact phrase “Incorrect password.”. Only one file contains this phrase - the filename called
“YourWordpressFolder\wp-includes\pluggable.php”.

How to reset WordPress administrator password - 1

We search this file for the “Incorrect password.” string.

find the right file

What do we have on line 450? The test.
if ( !wp_check_password($password, $user->user_pass, $user->ID) ) {
In plain English, it says : If the password is not good, then display error message, else log the user in.
We just change the above sentence to:
If the password is good, then display error message, else log the user in.
In other words, any WRONG password will get you logged.
We just have to remove the “not” word, which in PHP is the “!” character.
So, line 450 will become:
if ( wp_check_password($password, $user->user_pass, $user->ID) ) {

We upload the modified file and we login as admin, using any WRONG password.

Step 2: Change the password
Dashboard -> Users -> Your profile -> New password
Nobody will ask you for the old one :)

Step 3 : Change back the pluggable.php file and upload it.

Note : if you are very concerned with security, do step 3 before step 2. After you logged, nobody will ask you again for your password.

Please feel free to comment / ask questions.

How to change the numbers of attachments per page (dashboard)

Edit the file called “YourWordPressFolder/wp-admin/includes/post.php”

Look for the code below (should start around line 529)
function wp_edit_attachments_query( $q = false ) {
global $wpdb;
if ( false === $q )
$q = $_GET;
$q['m']   = (int) $q['m'];
$q['cat'] = (int) $q['cat'];
$q['post_type'] = ‘attachment’;
$q['post_status'] = ‘any’;
$q['posts_per_page'] = 15;

Change $q['posts_per_page'] to whatever you wish.

The default value for $q['posts_per_page'] is 15.

How to change the numbers of posts per page (dashboard)

Edit the file called “YourWordPressFolder/wp-admin/includes/post.php”

Look for the code below (should start around line 517) wp(”post_type=post&what_to_show=posts$post_status_q&posts_per_page=15
&order=$order&orderby=$orderby”);

Change $posts_per_page to whatever you wish.

The default value for $posts_per_page is 15.

How to change the numbers of pages per page (dashboard)

Edit the file called “YourWordPressFolder/wp-admin/pages.php”

Look for the code below (should start around line 122)
$pagenum = absint( $_GET['pagenum'] );
if ( empty($pagenum) )
$pagenum = 1;
if( !$per_page || $per_page < 0 )
$per_page = 20;
Change $per_page from the last row to whatever you wish.

The default value for $per_page is 20.

How to change the numbers of themes per page (dashboard)

Edit the file called “YourWordPressFolder/wp-admin/themes.php”

Look for the code below (should start around line 30)
$themes = get_themes();
$ct = current_theme_info();
ksort( $themes );
$theme_total = count( $themes );
$per_page = 15;
Change $per_page from the last row to whatever you wish.

The default value for $per_page is 15.

How to change the numbers of link categories per page (dashboard)

Edit the file called “YourWordPressFolder/wp-admin/edit-link-categories.php”

Look for the code below (should start around line 76)
$pagenum = absint( $_GET['pagenum'] );
if ( empty($pagenum) )
$pagenum = 1;
if( !$catsperpage || $catsperpage < 0 )
$catsperpage = 20;
Change $catsperpage from the last row to whatever you wish.

The default value for $catsperpage is 20.

How to change the numbers of categories per page (dashboard)

Edit the file called “YourWordPressFolder/wp-admin/categories.php”

Look for the code below (should start around line 139)
$pagenum = absint( $_GET['pagenum'] );
if ( empty($pagenum) )
$pagenum = 1;
if( !$catsperpage || $catsperpage < 0 )
$catsperpage = 20;
Change $catsperpage from the last row to whatever you wish.

The default value for $catsperpage is 20.