Exclude admin from the top commenters list [duplicate]

Assuming the comment_author is a User ID, try: if(user_can($result->comment_author,’manage_options’)){ $output .= “<li>”.(($result->comment_author_url) ? “<a href=””.$result->comment_author_url.””>” : “”).$result->comment_author.(($result->comment_author_url) ? “</a>” : “”).” (“.$result->comments_count.”)</li>”; } If not, one can use get_comment, and select the comment_ID in the SQL statement. You can then use the object returned to grab the user ID of the comments author, and do … Read more

How to have a category not show up in query post with page panigation?

When using cat in the query you need to specify the category id not name. Try this. <?php $gallery = get_cat_id(‘gallery’); $shirts = get_cat_id(‘shirts’); $hoodies = get_cat_id(‘hoodies’); $excluded_cats=”-“.$gallery.’,-‘.$shirts.’,-‘.$hoodies; $limit = 5; $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; query_posts( ‘cat=”.$excluded_cats.”&showposts=” . $limit . “&paged=’ . $paged ); ?>

Exclude Category From Home Page, Display Posts on It’s Own Page?

Rather than performing a separate query, to exclude a category (or any other taxonomy) term, you can hook into pre_get_posts: add_action(‘pre_get_posts’, ‘wpse41820_exclude_cat_from_front_page’); function wpse41820_exclude_cat_from_front_page( $query ){ if( $query->is_main_query() && is_front_page() ){ $tax_query = array(array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => array( 57 ), ‘operator’ => ‘NOT IN’ )); $query->set(‘tax_query’,$tax_query); } return $query; } … Read more

Problems with explode [closed]

It’s because you’ve created an array with explode and assigned it to $string, then you’re appending strings onto it when you use the .= concatenation operator within your foreach loop. here’s a simpler method: $string = ‘-‘ . implode( ‘,-‘, explode( ‘ ‘, $data[‘exclude_categories’] ) );

trouble with my loop

cat accepts category IDs, not slugs or names. a better method here is to use the pre_get_posts action, the Codex page has an example that does exactly what you’re trying to do.

Exclude Author by ID

Where $that_user_your_filtering_out is the user/author ID you wan’t to filter out, make this modification to your loop foreach ($blogusers as $bloguser) { // modification starts here if($bloguser->user_id == $that_user_your_filtering_out){ continue; } // modification ends here echo ‘<div class=”content-slider-body”>’; $user = get_userdata($bloguser->user_id);

Display 1 category only with get_the_category (by ID or slug)

I think you could do something like this: $categories = get_the_category(); $displayed_category_id = 1; // set this to the category ID you want to show $output=””; if($categories){ foreach($categories as $category) { if ( $displayed_category_id == $category->term_id) { $output .= ‘<a href=”‘.get_category_link($category->term_id ).'” title=”‘ . esc_attr( sprintf( __( “View all posts in %s” ), $category->name ) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)