How can I limit the number of comments per registered user per day?

You could pull all of the comments by current user and loop over them to see how may where today or you can create a custom sql Query to select just the count of comments for the last 24 hours, something like this: global $wpdb,$current_user; $sql = $wpdb->prepare(” SELECT count(*) FROM wp_comments WHERE comment_author=”%s” AND … Read more

Different number of posts in each category

As @StephenHarris pointed out there’s also the pre_get_posts filter. function hwl_home_pagesize( $query ) { if ( is_category( 9 ) ) { // If you want “posts per page” $query->query_vars[‘posts_per_page’] = 1; return; } if ( is_category( ‘movie’ ) ) { // If you want “showposts” $query->query_vars[‘showposts’] = 50; return; } } add_action( ‘pre_get_posts’, ‘hwl_home_pagesize’, 1 … Read more

Customizing get_the_excerpt() to specific length and “Read More” output.

To get a specific length you can use: wp_trim_words function. It has 3 parameters. Text to trim. Ex: get_the_content() Number of words. Ex: 295 What to append after end of the text. Ex: ” This means null. Use this: <span> <?php echo wp_trim_words( get_the_content(), 295, ” ); ?> <i><a style=”color:#1975D1;float:Right;” class=”title” href=”https://wordpress.stackexchange.com/questions/75069/<?php the_permalink() ?>” rel=”bookmark”>Click … Read more

Decrease file size upload in Media

That number is taken from wp_max_upload_size(), and there is a filter: ‘upload_size_limit’. See wp-admin/includes/template.php. So this should work (not tested): add_filter( ‘upload_size_limit’, ‘wpse_70754_change_upload_size’ ); function wpse_70754_change_upload_size() { return 1000 * 1024; }

Changing the username character limit from four to less characters

You can filter ‘wpmu_validate_user_signup’ and check if the error code matches the 4 character warning. Then just unset the error code. Sample plugin: <?php # -*- coding: utf-8 -*- /* Plugin Name: Allow short user names for multi site. */ add_filter( ‘wpmu_validate_user_signup’, ‘wpse_59760_short_user_names’ ); /** * Allow very short user names. * * @wp-hook wpmu_validate_user_signup … Read more

Can I hook into user registration *before* a user is created?

You’re looking in the wrong place. When a user first attempts to register, their username and email is processed and sanitized inside the register_new_user() function in wp-login.php. This is where you want to do your filtering. Before the user is created, WordPress will pass the sanitized user login, email address, and an array or errors … Read more

Remove more or […] text from short post

The codex is your friend and should be your first stop 🙂 The […] is added by the_excerpt(). There is a filter supplied called the excerpt_more filter that is specifically included to customize the read more text after the excerpt To remove the […] after the excerpt text, you can do the following function new_excerpt_more( … Read more