Show all posts for a specific category/author

The number of posts displayed in any loop by default is controlled by Settings > Blog pages show at most. To show all posts, you can enter a huge number, but -1 (which is the value to use for the posts_per_page paramerter in WP_Query) does not work here. It is possible to show all posts … Read more

get_attached_media() on author page not working

I assume that you have a simple misunderstanding of what this function actually does and what it should be used for: get_attached_media() simply fetches all child posts for a given posts: if ( ! $post = get_post( $post ) ) return array(); $args = array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => $type, ‘posts_per_page’ … Read more

popular post weekly and monthly

These $args is what you need and you may also use that in query_posts(); $args = array( ‘post_type’ => array( ‘post’ ), ‘post_status’ => ‘publish’, ‘posts_per_page’ => 9, ‘cat’ => $link1, // try better variable name ‘meta_key’ => ‘post_views_count’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘date_query’ => array( array( ‘after’ => ‘1 months ago’, ), … Read more

Transient loop issue

The reason it’s only storing the first post data is because you’re using the same transient name for each post. If you want to store multiple movie transients, you need unique names for each movie. Also, the way you’re getting the transient defeats the purpose of using transients. You want to first try to get … Read more

Using get_the_excerpt() Before The Loop

So you are basically also looking for a fallback in case your excerpt is empty? I suppose this question/answer could be helpful for you: “get_the_excerpt() with fallback like the_excerpt()“. It describes, how to build your own “excerpt” in case there is none – like this: $excerpt = get_the_content(); $excerpt = esc_attr( strip_tags( stripslashes( $excerpt ) ) … Read more

Five posts from a category in footer

First: don’t use query_posts. Second: use $wp_query instead: $args = array ( ‘category_name’ => ‘entertainment’, ‘posts_per_page’=> 5 ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) { echo ‘<ul>’; while ( $the_query->have_posts() ) { $the_query->the_post(); echo ‘<li>’ . get_the_title() . ‘</li>’; } echo ‘</ul>’; /* Restore original Post Data */ wp_reset_postdata(); } else … Read more

Prevent Headers from being sent

“Headers already sent” is not a WordPress error, it is PHP processing error message. Good explanation here; https://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php . I suspect it might be caused by some characters (probably space characters) sent before your <?php code segment. Even space (or tab [code formatting] ) characters will cause an error. And perhaps move your <ul> code … Read more