
Usage Instructions
Open wp-content/themes/
Find:
|
1 2 3 |
<?php while (have_posts()) : the_post(); ?>
|
Add Anywhere Below It:
|
1 2 3 |
<?php if(function_exists('wp_print')) { print_link(); } ?>
|
If you DO NOT want the print link to appear in every post/page, DO NOT use the code above. Just type in:
|
1 |
[print_link] |
into the selected post/page content and it will embed the print link into that post/page only.
The first value is the text for printing post.
The second value is the text for printing page.
Default: print_link(”, ”)
Alternatively, you can set the text in ‘WP-Admin -> Settings -> Print’.
Go to ‘WP-Admin -> Settings -> Print’ to configure the style of the print text link.
If you do not want to print a portion of your post’s content, do the following:
|
1 |
[donotprint]Text within this tag will not be displayed when printing[/donotprint] |
The text within donotprint tags will not be displayed when you are viewing a printer friendly version of a post or page.
WP-Print will load ‘print-css.css’, ‘print-posts.php’ and ‘print-comments.php’ from your theme’s directory if it exists. If it doesn’t exists, it will just load the respective default file that comes with WP-Print. This will allow you to upgrade WP-Print without worrying about overwriting your printing styles or templates that you have created.
Placing this php code within the wordpress functions.php file in your theme will enable excerpts for pages.
|
1 2 3 4 5 6 |
function page_excerpt() {
add_post_type_support('page', array('excerpt'));
}
add_action('init', 'page_excerpt');
|
This is the most simple of wordpress shortcodes. Placing [mysite] within your post will be replaced by the hyperlink within the mysite function. Place this code within the functions.php of your wordpress theme.
|
1 2 3 4 5 6 |
function mysite(){
return '<a href="http://mysite.com">visit my website</a>';
}
add_shortcode('mysite', 'mysite');
|
Adding this code to your functions.php will redirect subscribers away from wp-admin to the home page.
|
1 2 3 4 5 6 7 8 9 10 11 |
if ( is_user_logged_in() && is_admin() ) {
global $current_user;
get_currentuserinfo();
$user_info = get_userdata($current_user->ID);
if ( $user_info->wp_user_level == 0 )
{
header( 'Location: '.get_bloginfo('home').'/wp-login.php?redirect='.get_bloginfo('home').'/wp-admin/' );
}
}
|
Adding this PHP code to the functions.php of your wordpress theme will increase the height of your WYSIWYG editor.
|
1 2 3 4 5 6 7 8 9 10 |
add_action('admin_head', 'content_textarea_height');
function content_textarea_height() {
echo'
<style type="text/css">
#content{ height:500px; }
</style>
';
}
|
Adding this to your .htaccess will help keep bots from posting comments on your wordpress blog, be sure to change yourdomain.com to your website address.
|
1 2 3 4 5 6 7 8 |
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
RewriteCond %{HTTP_REFERER} !.*yourdomain.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) http://%{REMOTE_ADDR}/$ [R=301,L]
|
Adding this to your .htaccess will prevent access to your wp-config.php file.
|
1 2 3 4 5 6 |
<files wp-config.php>
order allow,deny
deny from all
</files>
|
Adding this PHP code snippet to the functions.php of your wordpress theme will notify users of new posts. Please note that this snippet is best used for low volume sites. Large websites should consider alternative options.
|
1 2 3 4 5 6 7 8 9 10 |
function email_members($post_ID) {
global $wpdb;
$usersarray = $wpdb->get_results("SELECT user_email FROM $wpdb->users;");
$users = implode(",", $usersarray);
mail($users, "New WordPress post online", 'A new post has been published on http://www.wpsnipp.com');
return $post_ID;
}
add_action('publish_post', 'email_members');
|
Adding this PHP code to the functions.php of your wordpress theme will allow you to customize the order of the admin menu items.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
function custom_menu_order($menu_ord) {
if (!$menu_ord) return true;
return array(
'index.php', // this represents the dashboard link
'edit.php?post_type=events', // this is a custom post type menu
'edit.php?post_type=news',
'edit.php?post_type=articles',
'edit.php?post_type=faqs',
'edit.php?post_type=mentors',
'edit.php?post_type=testimonials',
'edit.php?post_type=services',
'edit.php?post_type=page', // this is the default page menu
'edit.php', // this is the default POST admin menu
);
}
add_filter('custom_menu_order', 'custom_menu_order');
add_filter('menu_order', 'custom_menu_order');
|
Adding this PHP code to the functions.php of your wordpress theme will allow you to add a custom admin footer.
|
1 2 3 4 5 6 |
function adminFooter() {
echo 'Content to be displayed within the admin footer';
}
add_filter('admin_footer_text', 'adminFooter');
|