WordPress snippets 2023

Written by 25.05.2019

WordPress Code Snippets

Disable WordPress database revisions:

wp-config.php add above ‘require-once’:
define('WP_POST_REVISIONS', false);  

Delete revisions from WordPress database:

Perform the following SQL query on your database in PHPMyAdmin

DELETE FROM `wp_posts` WHERE `post_type` = "revision" AND `post_name` LIKE "%revision%"

Customize “Read more” button

functions.php

function modify_read_more_link() {
    return <a class="more-link" href='"' . get_permalink() . '">'. __("Читать далее", "Divi") .'</a>';
}
add_filter( 'the_content_more_link', 'modify_read_more_link' );

Add “Read more” button for excerpts

functions.php

add_filter( 'wp_trim_excerpt', function( $excerpt ) {
	$excerpt = sprintf( '%1$s&lt;br&gt;&lt;a class="more-link" href="%2$s"&gt;%3$s&lt;/a&gt;',
			$excerpt,
			get_permalink(),
			__("Read more", "Divi"));
	return $excerpt;
});

Leave a Reply

Your email address will not be published. Required fields are marked *