Skip to content

Instantly share code, notes, and snippets.

View Number Post - Home, Cat, Individual Cat
function hwl_home_pagesize( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return;
if ( is_home() ) {
// Display only 3 posts
$query->set( 'posts_per_page', 3 );
return;
}
@jfcode
jfcode / Home & Category Number
Created May 20, 2014
Control number of posts on home page and category
View Home & Category Number
function hwl_home_pagesize( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return;
if ( is_home() ) {
// Display only 3 posts
$query->set( 'posts_per_page', 3 );
return;
}
View Home Page Post Number
function hwl_home_pagesize( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return;
if ( is_home() ) {
// Display only 3 posts
$query->set( 'posts_per_page', 3 );
return;
}
}
View Hide Add Media Button
function RemoveAddMediaButtonsForNonAdmins(){
if ( !current_user_can( 'manage_options' ) ) {
remove_action( 'media_buttons', 'media_buttons' );
}
}
add_action('admin_head', 'RemoveAddMediaButtonsForNonAdmins');
View Access Own Media Only
/**
* Allow access to own content only
*/
function my_authored_content($query) {
//get current user info to see if they are allowed to access ANY posts and pages
$current_user = wp_get_current_user();
// set current user to $is_user
$is_user = $current_user->user_login;
View Code 1 Public
<?php if ( is_user_logged_in() ) { ?>
<?php $user_info = get_userdata(get_current_user_id());
global $current_user;
get_currentuserinfo();
echo get_avatar( $current_user->ID, 200 );
echo '<br />';
echo '<br />';
echo 'Welcome, ' . $user_info->user_login . "!" . "\n";
echo '<br />';
echo '<br />';