Query sub subpages based on specific date?

If you’re loading additional posts/pages, it’s better to use a new WP_Query instance. query_posts is only for modifying the main query. As for the dates, store them in a custom field in the format yyyy-mm-dd. You’ll use php’s date to get the current date, refer to WP_Query’s custom field parameters for how to query and … Read more

Conditional sidebar menu

Bainternet’s solution will definitely work, but it you want to use the page slug instead of ID you could put this in your functions.php file: // GET PAGE ID FROM THE SLUG, HELPER FUNCTION FOR IS_TREE function get_ID_by_slug($page_slug) { $page = get_page_by_path($page_slug); if ($page) { return $page->ID; } else { return null; } } // … Read more

404 error on second page load for child-pages

I never found the real reason for this issue. However this “bugfix” did solve the issue for me: add_action( ‘template_redirect’, ‘handle_strange_bug’, 10 ); // “Fixes” the strange bug… function handle_strange_bug() { global $post; $post_id = 123; // This is the post that makes problems. /* ===== Start of the bugfix. * * If the $post->ID … Read more

Get current post’s child page?

$ancestors = array(); $ancestors = get_ancestors($post->ID,’page’); $parent = (!empty($ancestors)) ? array_pop($ancestors) : $post->ID; $parent should be the topmost page parent. However, if you are using a WordPress generated menu there is a pretty good chance that there is already a item identified by a CSS class as the parent. Take a good look at the … Read more