Tag Info

Hot answers tagged

6

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. * ...


5

To display 5 posts, say, use posts_per_page. See the Codex. $the_query = new WP_Query( array( 'brand' => 'sony-vaio','posts_per_page'=>5 ) );


4

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; }


3

first add this function to your functions.php file function max_title_length($title){ $max = 20; return substr( $title, 0, $max ). " &hellip;"; } then before the loop of the code you linked add this line to hook the above function: add_filter( 'the_title', 'max_title_length'); and after the loop remove this filter: remove_filter( ...


3

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 through the ...


3

I think the answer is in the source. $username = wp_strip_all_tags( $username ); $username = remove_accents( $username ); // Kill octets $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username ); $username = preg_replace( '/&.+?;/', '', $username ); // Kill entities // If strict, reduce to ASCII for max portability. if ( $strict ) ...


3

You can use the pre_get_posts hook (conditionals are available): function wpse47875_change_posts_per_page( $query ) { //Only alter main query. This only works for 3.3+ if( ! $query->is_main_query() ) return; if ( is_category('9') ){ //Display 4 posts for category 1 $query->set( 'posts_per_page', 4); } } ...


3

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" ...


3

There are some restrictions (caused by lengths of some columns in database). Taxonomies Taxonomy name - 32 characters Term name (and term slug) - 200 characters Posts Post type name - 20 characters Post name (slug) - 200 characters Meta key - 255 characters Options Option name - 64 characters Comments Commenter email - 100 characters ...


3

As you can see in the WordPress Option Reference, there's an option called users_can_register. You can - per default - set it in your (network-)sites settings. 1 => Yes 0 => No As usual: There's a filter to intercept that from a plugin. "option_{$option_name}" So you can simply attach a callback to this filter and check the amount of users with a ...


2

Piggybacking off Kaiser's answer: add_filter( 'option_users_can_register', 'limit_total_users' ); function limit_total_users( $option ) { // We've already achieved our goal if this rings true, let's leave if ( 0 === $option ) return $option; $limit = 50; $user_count = count_users(); // Abort if we're above the limit if ...


2

This solution differs from the others in that the primary work in done on user registration. After a user registers the total users are counted and the users_can_register option is updated if necessary. That seems to be the best way to minimize front-end processing time. A related function hooked to pre_option_users_can_register prevents blog admins from ...


2

First, please make sure you understand the difference between the_excerpt and the_content. You are asking about the_excerpt but I suspect that you might actually mean the_content. That said... You can filter the the_excerpt function with a filter of the same name. add_filter( 'the_excerpt', function ($excerpt) { return ...


2

I took the example code from the Wordpress user_has_cap filter codex page and modified it. Add this code to your theme functions.php: function restrict_editing_old_posts( $allcaps, $cap, $args ) { // Bail out if we're not asking to edit or delete a post ... if( ( 'edit_post' != $args[0] && 'delete_post' != $args[0] ) // ... or user is admin ...


2

The signup page has validation hooks. How about something like this? add_filter('wpmu_validate_blog_signup','set_blog_creation_limit'); function set_blog_creation_limit($result) { $blogs = get_blogs_of_user($result['user']->ID); if (count($blogs) > 2 ) $result['errors']->add('blogname', __('You have already registered the maximum ...


2

The problem is that the_excerpt() strips all HTML. There's a good reason for this: what if the 49th word of a 50 word excerpt was the first word of a bulleted list? Or the second word in an <h1>? The way I would work around this is by using post thumbnails. These allow you to have an image you can choose to display at different sizes (or not at all) ...


2

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 ...


2

Adjust the amount of visible comments in the Screen Options:


2

In the form you have posted this is more of PHP question - you could use strlen() functions to determine length of original title and apply ellipsis conditionally. However in WP context you should consider using wp_trim_words() since trimming based on words looks tidier and it will take care of appending string of your choice whet cutting.


2

We had a similar problem where we needed to give access to partners and "membership" or "subscription" plugins seemed to offer what we needed. The problem we had was that the plugins we found were all for-pay, not free or freemium. Understanding this, the MagicMembers and aMember Pro plugins both had functions that could prevent access sharing. I'm sure ...


2

for ($i=1; $i <= min($pages,10); $i++)


2

The warning notice gets dispatched by the function wp_check_post_lock. The following redirects the user back to the post listing screen if someone else is editing it. add_action( 'load-post.php', 'redirect_locked_post_wpse_95718' ); function redirect_locked_post_wpse_95718() { if( isset($_GET['post'] ) && wp_check_post_lock( $_GET['post'] ) ) ...


2

This seem to work. Put in your functions.php: add_filter('pre_get_posts', 'limit_pages'); function limit_pages($query) { $query->max_num_pages = 5; if ($query->query_vars['paged'] > 5) { $query->query_vars['paged'] = 5; $query->query['paged'] = 5; } return $query; } But I guess you would still need some ...


2

Simple solution is to add a maxlength attribute to the textarea field. For example <textarea maxlength="140"> </textarea>


1

Just tested with WordPress 3.4.2 and 3.5.2-beta2. With 317 files, this issue does not comes up (order or maximum number of shown items).


1

You can use something like jQuery Simply Countable plugin and attach it to excerpt input. Limit_Excerpt_Words::on_load(); class Limit_Excerpt_Words { static function on_load() { add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) ); } static function admin_enqueue_scripts() { global ...


1

This is a little tricky, and my solution may not be the best for the performance. You may add this Value as a Custom Field to the Page, so you do not have to query it everytime. // get the ancestors of the page, and check if the page is toplevel $parent = array_reverse( get_post_ancestors( $post->ID ) ); if ( isset( $parent[0] ) ) { $toplevel = ...


1

You cannot change that value. The database schema is limited to 20 Bytes. See wp-admin/includes/schema.php: TABLE $wpdb->posts ( ID bigint(20) unsigned NOT NULL auto_increment, post_author bigint(20) unsigned NOT NULL default '0', post_date datetime NOT NULL default '0000-00-00 00:00:00', post_date_gmt datetime NOT NULL default '0000-00-00 ...


1

Important Link: Posts Creation Limits Dig into this plugin you easily get the code for limit posts/pages.


1

There is no category argument for query_posts, a category ID should be passed via cat. However, if this is an additional query, please use WP_Query rather than query_posts. If this is the main query, please see pre_get_posts to alter the main query parameters. For more info please see When to use WP_query(), query_posts() and pre_get_posts.



Only top voted, non community-wiki answers of a minimum length are eligible