Add filter to wp_dropdown_pages() or wp_dropdown_categories() – no select container?

A filter called wp_dropdown_pages exists in the wp_dropdown_pages() function. That filter allows you to modify the output of the function. However, for the thing you want to do I would not recommend using this filter since this will apply to all code that calls wp_dropdown_pages(), including plugins. So, one way to approach your situation may … Read more

Load parent pages when there are no child pages

possible code: <?php $children = wp_list_pages(‘title_li=&child_of=”.$post->ID.”&echo=0&depth=1’); if ($children) { ?> <ul id=”three-menu”> <?php echo $children; ?> </ul> <?php } //ends (if($children)// elseif($post->post_parent) { //if no children, try to get parent page and show siblings pages including the page itself $siblings = wp_list_pages(‘title_li=&child_of=”.$post->post_parent.”&echo=0&depth=1’); if ($siblings) { ?> <ul id=”three-menu”> <?php echo $siblings; ?> </ul> <?php } … Read more

how to properly list child pages in sidebar?

Here is the code that satisfies all your 3 requirements above. <?php /* * get_page_depth * Gets the page depth, calls get_post on every iteration * https://gist.github.com/1039575 */ if ( !function_exists( ‘get_page_depth’ ) ) { function get_page_depth( $id=0, $depth=0 ) { global $post; if ( $id == 0 ) $id = $post->ID; $page = get_post( … Read more

Change ul class=”children” for wp_list_pages?

You can override this by supplying your on Walker Object when calling wp_list_pages, like this: <your-template>.php wp_list_pages(array( ‘title_li’ => null, ‘depth’ => 2, ‘child_of’ => 0, ‘walker’ => new My_Walker(), )); Instead of the default Walker_Page this will make wp_list_pages use your custom walker, My_Walker. The only difference we need here is to make your … Read more

How to show only parents subpages of current page item in vertical menu?

Finally, I solved it myself. Here is the solution: In functions.php: function show_all_children($parent_id, $post_id, $current_level) { $top_parents = array(); $top_parents = get_post_ancestors($post_id); $top_parents[] = $post_id; $children = get_posts( array( ‘post_type’ => ‘page’ , ‘posts_per_page’ => -1 , ‘post_parent’ => $parent_id , ‘order_by’ => ‘title’ , ‘order’ => ‘ASC’ )); if (empty($children)) return; echo ‘<ul class=”children … Read more

Add class to the items in wp_list_pages

As wp_list_pages() has an argument of walker, you can use that to replace what is being used by walk_page_tree() as walker class internally. @Brady has left a nice example in this answer. class WPSE113482PageWalker extends Walker_Page { function start_el( &$output, $page, $depth, $args, $current_page ) { // Build $output here and apply your class for … Read more

get all page IDs from wp_list_pages

wp_list_pages() is for formatted markup. Use get_pages() and wp_list_pluck(): $pages = get_pages( array ( ‘parent’ => 0, // replaces ‘depth’ => 1, ‘exclude’ => ‘3,5,11’ ) ); $ids = wp_list_pluck( $pages, ‘ID’ ); $ids holds an array of page IDs now.

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