How To Load All Posts From The Current Week
Using the following snippet and you will be able to load posts from the current week.
1 2 3 4 5 6 |
// display posts as desired query_args = array( 'w' => date( 'W' ), 'year' => date( 'Y' ), ); $posts = get_posts( $query_args ); |
Source Snippet/Code: Christian Brückner
How To Add A Custom Message To The Editor Pane
Simply by copying the following snippet in your theme’s functions.php file, you will be able to add a custom message to the editor pane.
1 2 3 4 5 6 7 8 9 |
function wptutsplus_text_after_title( $post_type ) { ?> <div class="after-title-help postbox"> <h3>Using this screen</h3> <div class="inside"> <p>Use this screen to add new articles or edit existing ones. Make sure you click 'Publish' to publish a new article once you've added it, or 'Update' to save any changes.</p> </div><!-- .inside --> </div><!-- .postbox --> <?php } add_action( 'edit_form_after_title', 'wptutsplus_text_after_title' ); |
Snippet Source/Credit: WP Tuts
How To Remove Widgets From WordPress Dashboard
Simply paste the following snippet in your theme’s functions.php file and you will be able to accomplish the task.
1 2 3 4 5 6 7 |
//Remove unwanted widgets from Dashboard function remove_dashboard_widgets() { global$wp_meta_boxes; unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); } add_action('wp_dashboard_setup', 'remove_dashboard_widgets'); |
Snippet Source/Credit: WP Guru
How To Delete WordPress Post Revisions Using Your Functions.php File
Simply paste the following snippet in your functions.php file and you are done.
1 2 3 4 |
$wpdb->query( " DELETE FROM $wpdb->posts WHERE post_type = 'revision' " ); |
Snippet Source/Credit: Hardeep Asrani
How To Limit Posts Per Page On Search
Just paste the following snippet in your functions.php file and replace the number on line 3 by the desired number of posts you wish to display and you are done.
1 2 3 4 5 |
function limit_posts_per_search_page() { if ( is_search() ) set_query_var('posts_per_archive_page', 20); } add_filter('pre_get_posts', 'limit_posts_per_search_page'); |
Snippet Source/Credit: WordPress.org