thrillphase
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Fixing WordPress
In reply to: Include specific pages in query and sort by order in menuI wanted to thank you for pointing me in the right direction and provide the code that is currently working for me. (wp 3.7.1)
-in functions.php:// Menu item IDs function grab_menu_items(){ $menu_name = 'primary'; if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) { $menu = wp_get_nav_menu_object( $locations[ $menu_name ] ); $menu_items = wp_get_nav_menu_items($menu->term_id); $theidlist = array(); foreach ( (array) $menu_items as $key => $menu_item ) { $theidlist[] = $menu_item->object_id; } return $theidlist; } else { return; } }-and the query:
$menuitems = grab_menu_items(); /* Query */ $the_query = new WP_Query( array( 'post_type' => 'page', 'orderby' => 'post__in', 'posts_per_page' => '-1', 'post__in' => $menuitems ) ); /* The Loop */ while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <div id="box<?php the_ID(); ?>" class="shadow-box"><?php the_excerpt(); ?><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark">read more</a></div> <?php endwhile; /* Restore original Post Data */ wp_reset_query();I had a similar issue with custom fields not showing up in the drop down menu, seems like having the custom field exist is not enough, it needs to have been used.
After creating a dummy custom post with all custom fields populated, the drop down options were all there.
Viewing 2 replies - 1 through 2 (of 2 total)