How To Break Names Into Two Lines
The snippet will let you break names into two lines.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// split name if (!function_exists('the_title')) { function the_title($name) { if($name!='') { return get_the_title($name); } else return false; } } if (!function_exists('split_name')) { function split_name($name) { if(strpos($name,' ')!==FALSE) { $name_arr = explode(' ',$name); if(count($name_arr)==2) { return $name_arr[0].'<br/>'.$name_arr[1]; } elseif(count($name_arr)==3) { return $name_arr[0].' '.$name_arr[1].'<br/>'.$name_arr[2]; } else { return $name; } } else { return $name; } } } // Template usage - echo split_name(get_the_title()); |
Snippet Source/Credit: FlashAlexander
How To Form Standard WordPress Comment
The snippet will let you form standard WordPress comment.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
<div id="respond"> <!-- START TITLE LEAVE A REPLY --> <h2 id="leave-reply">Lascia un commento</h2> <!-- END TITLE LEAVE A REPLY --> <?php if ( get_option('comment_registration') && !$user_ID ) : ?> <!-- START MESSAGE REQUEST REGISTRATION COMMENTS --> <p><?php printf(__('Devi eseguire il <a href="%s">login</a> per inserire un commento.', 'yiw'), get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode(get_permalink())); ?></p> <!-- END MESSAGE REQUEST REGISTRATION COMMENTS --> <?php else : ?> <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"> <?php if ( $user_ID ) : ?> <p><?php printf(__('Sei loggato come <a href="%1$s">%2$s</a>.', 'yiw'), get_option('siteurl') . '/wp-admin/profile.php', $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php _e('Log out da questo account', 'yiw'); ?>"><?php _e('Log out »', 'yiw'); ?></a></p> <?php endif; ?> <textarea name="comment" id="comment" cols="100%" rows="10" tabindex="1"></textarea> <?php if ( !$user_ID ) : ?> <p> <label for="author">Nome <?php if ($req) _e(" (richiesto)", 'yiw'); ?></label> </p> <p> <input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" tabindex="2" /> </p> <p> <label for="email">Mail <?php if ($req) _e(" (richiesto)", 'yiw'); ?></label> </p> <p> <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" tabindex="3" /> </p> <p> <label for="url">Website</label> </p> <p> <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" tabindex="4" /> </p> <?php endif; ?> <p> <input name="submit" type="submit" id="submit" tabindex="5" value="Invia Commento" /> <?php comment_id_fields(); ?> </p> <?php do_action('comment_form', $post->ID); ?> </form> <?php endif; ?> </div><!-- #respond --> |
Snippet Source/Credit: Snipplr
How To Change Role Access To Menu And Widgets
By default, for changing menu and widgets, one will be requiring admin user roles. But, with the snippet below, you will be able to change role access to menu and widgets.
1 2 3 4 5 6 |
<?php // get the the role object $role_object = get_role('editor'); // add $cap capability to this role object $role_object->add_cap('edit_theme_options'); ?> |
Snippet Source/Credit: WP-Snippets.com
How To Create Database For WordPress
Using the following snippet, you will be able to create database for WordPress.
1 2 |
CREATE SCHEMA `your_db_name` ; GRANT ALL PRIVILEGES ON your_db_name.* TO 'your_user_name'@'localhost' IDENTIFIED BY 'your_password'; |
Snippet Source/Credit: Snipplr
How To Execute Shortcode From Custom Field
The following snippet will let you execute shortcode from custom field.
1 |
<?php echo apply_filters('the_content', get_post_meta($post->ID, 'your_custom_field_here', true)); ?> |
Snippet Source/Credit: Leeboyce