Want Page Descendants when using query_posts post_parent or child_of

If you don’t have to use query_posts() then this is one method: function my_menu() { global $post; if(!$post->post_parent){ // will display the subpages of this top level page $children = wp_list_pages( array( ‘title_li’ => ”, ‘child_of’ => $post->ID, ‘echo’ => 0 ) ); } elseif($post->ancestors){ // diplays only the subpages of parent level $ancestors = … Read more

Sticky posts don’t show up first in custom loop

DO NOT USE query_posts() FOR CUSTOM LOOPS! Use WP_Query() instead. <?php $paged = get_query_var( ‘paged’ ) ? get_query_var( ‘paged’ ) : 1; $custom_cat_query_args = array( ‘paged’ => $paged, ‘category_name’ =>’home,tumblr’ ); $custom_cat_query = new WP_Query( $custom_cat_query_args ); By default, ignore_sticky_posts is set to 0, or do not ignore. So, the custom loop should handle sticky … Read more

Weird problem on if statement

there is no third parameter for get_field, may be causing your error. EDIT- In your current code, if the 10 most recent posts don’t contain a post with your meta key, you’ll see nothing since you’re only getting 10 posts and then filtering them. Any query that doesn’t specify number of posts defaults to your … Read more

If Query Post Returns 1 Post

You should not use query_post when you can use the mutch faster query WP_Query. You can count the post with the property post_count. Here is a snippet that counts your post in the loop: <?php $args = array( ‘post_type’ => ‘post’, ‘cat’ => ’20’, ‘post_status’ => ‘publish’, ‘order’ => ‘DESC’ ); // The Query $the_query … Read more

View Achive with Category Filter, but Page per post not working

The problem is that you’re stomping the main query by using query_posts(). Don’t do that. Instead, filter the main query via pre_get_posts: function wpse82113_filter_pre_get_posts( $query ) { if ( is_category( 7 ) && $query->is_main_query() ) { $query->set( ‘posts_per_page’, ‘6’ ); } } add_action( ‘pre_get_posts’, ‘wpse82113_filter_pre_get_posts’ );

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