WordPress Search Filter Only for Page with Child of Child of Child of Child of Child

You can probably do something like this. It’s probably less efficient, but should find all descendants of a given page rather than just direct children. function find_descendants($post_id) { $descendant_ids = array(); $pages = get_pages(“child_of=$post_id”); foreach ($pages as $page) { array_push($descendant_ids, $page->ID); } return $descendant_ids; } function SearchFilter($query) { if ($query->is_search) { $query->set ( ‘post__in’, find_descendants(21) … Read more

Counter code for paginated category pages in wordpress

Yes, of course it starts again at 1. You’ve initialized the counter to 1 on each page load. If you were writing a custom loop you’d do this: $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; If normal WordPress pagination mechanisms are working on your page that should work for you too. That will number your … Read more

how could I get the pagination as I want to when query posts using get_posts function

Use paginate_links. It is meant to do pretty much just that. Plus, the ordinary pagination functions like next_posts_link (which I think you want instead of next_post_link) do not work reliably with custom queries, but next_post_link and previous_post_link are equally or more troublesome with custom queries. With paginate_links you need to pass quite a bit of … Read more

Total Count of Posts NOT in Selected Categories?

Do your posts have multiple categories? If not – I think individual category counts are cached, so can sum up counts: $categories = get_categories( array( ‘exclude’ => $folio_cat_ids ) ); $count = 0; foreach ( $categories as $category) $count += $category->category_count; Can also just get and count the posts, that is more flexible and takes … Read more

Query posts by taxonomy term name

I’m not sure if the get_posts function supports the tax_query. You might want to try creating a new WP_Query object instead. $args = array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘store’, ‘field’ => ‘name’, ‘terms’ => $mystorename ) ) ); $query = new WP_Query($args); if ( $query -> have_posts() ) : while ( $query -> … Read more