How do you change the comment count in the back end posts list, to reflect unapproved comments, rather than all comments?

Add following code in your theme’s functions.php. // To add extra column in column headers add_filter(‘manage_posts_columns’, ‘bs_event_table_head’); function bs_event_table_head( $defaults ) { $defaults[‘pending_comments’] = ‘Pending Comments’; return $defaults; } // To add data in column for each post. add_action( ‘manage_posts_custom_column’, ‘bs_event_table_content’, 10, 2 ); function bs_event_table_content( $column_name, $post_id ) { if ($column_name == ‘pending_comments’) { … Read more

how to wordpress When I click on the category link, subcategories appear

Here’s how you get all top-level categories and loop them to create a list of links, $parent_categories = get_categories( array( ‘fields’ => ‘id=>name’, // other term data no needed here ‘parent’ => 0, )); $parent_category_links = array(); foreach ($parent_categories as $parent_category_id => $parent_category_name) { $parent_category_links[] = sprintf( ‘<li><a href=”%s”>%s</a></li>’, esc_url( get_term_link( $parent_category_id, ‘category’ )), esc_html( … Read more

Conditionals if tags exist?

Try this <?php $related = new WP_Query( ‘tag=’ . get_the_title() . ” ); if( $related->have_posts() ): <h1>Related Articles</h1> while ( $related->have_posts() ) : the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/48774/<?php the_permalink() ?>”><?php the_title(); ?></a> </li> <?php endwhile; else: //there are no related articled endif; wp_reset_postdata();?> EDIT You should not use query_posts for a secondary loop. The query_posts alters … Read more

Authors & profiles (and exclude ID’s)

First, let me say that it is not “Strangely” working using ‘subscribers’ role. Note that you are taking out the ‘subscriber’ role from the results. The correct way to get only authors and exclude some IDs is using the role and exclude arguments of get_users() function: <?php $args = array( ‘role’ => ‘author’, //authors with … Read more

Author list based on recently active

I would take a different approach to this using a direct database query to get a list of author IDs ordered by recent posts. global $wpdb; $user_ids = $wpdb->get_results( ” SELECT DISTINCT post_author FROM $wpdb->posts ORDER BY post_date DESC ” ); if ( $user_ids ) { foreach ( $user_ids as $user_id ) { $user = … Read more

Categories list loop – add separator every 3 categories [closed]

<?php $args=array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ) $count=1; // A $count variable ?> <?php foreach (get_categories( $args ) as $cat) : if($count%3==0) // This condition will be true for 3,6,9,12………. { //Your Code — } $count++ // Increment $count variable ?> <h3><a href=”https://wordpress.stackexchange.com/questions/246349/<?php echo get_category_link($cat->term_id); ?>”><?php echo $cat->cat_name; ?></a></h3> <a href=”https://wordpress.stackexchange.com/questions/246349/<?php echo get_category_link($cat->term_id); … Read more

Get parent of current page

Try using get_post_ancestors. Here is how you can apply this in your case: <?php global $wp_query; $post = $wp_query->post; $ancestors = get_post_ancestors($post); if( empty($post->post_parent) ) { $parent = $post->ID; } else { $parent = end($ancestors); } if(wp_list_pages(“title_li=&child_of=$parent&echo=0” )) { wp_list_pages(“title_li=&child_of=$parent&depth=1” ); } ?> You’ll probably need to remove the depth parameters to show you’re 3rd … Read more

How to replace “Password Protected” text with icon in Admin

Try this (don’t forget to replace icon URL): add_filter( ‘display_post_states’, ‘password_protected_icon’ ); function password_protected_icon( $post_states ) { $text = __(‘Password protected’); $pos = array_search( $text, $post_states); if( false !== $pos ) $post_states[$pos] = ‘<img src=”http://i.stack.imgur.com/aIDa6.png” title=”‘.htmlspecialchars($text).'”/>’; return $post_states; }

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