Show links to child pages on both parent AND child pages

This seemed to work nicely for me; <?php $children = get_pages(‘child_of=”.$post->ID); if( count( $children ) != 0 ) { $id = $post->ID; } else { $id = $post->post_parent; } $args = array( “post_type’ => ‘page’, ‘post_parent’ => $id, ‘posts_per_page’ => -1 ); $system_query = new WP_Query($args); if ($system_query->have_posts()) : while ($system_query->have_posts()) : $system_query->the_post(); ?> <!– … Read more

Pagination not working with custom loop

I’ve run into this problem with PageNavi before. My solution is to hijack the $wp_query variable temporarily and then reassign it after closing the loop. An exmaple: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args=array( ‘post_type’=>’post’, ‘cat’ => 6, ‘posts_per_page’ => 5, ‘paged’=>$paged ); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query($args); /* … Read more

Find all posts via SQL beginning with A of type B

Try this.. SELECT * FROM $wpdb->posts p INNER JOIN $wpdb->term_relationships tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id=tt.term_taxonomy_id inner join $wpdb->terms t on t.term_id=tt.term_id and t.slug=’igralni’ WHERE p.post_title LIKE ‘А%’ AND p.post_type=”filmi-i-serialii” AND p.post_status=”publish”