I'm trying to figure out something that should be fairly easy I think. I have custom fields named 'include-in-nav'. I'm using wp_nav_menu() to create a menu:
wp_nav_menu( array( 'theme_location' => 'primary',
'menu_id' => 'primary-menu',
'include' => $post_ids
)
);
I've tried to get an array with post id's based on wether 'include-in-nav' is true or not. I've tried get_posts() and WP_query() but whatever i'm trying, nothing seems to return an array with post ID's. Any suggestions?
-edit my attempt to get $post_ids:
$post_ids = get_posts(array(
'post'
'meta_value' => 'include-in-main-nav'
));
and
$nav_posts = array(
'meta_value' => 'include-in-main-nav'
));
$wp_query = new WP_Query($nav_posts);
$post_ids = array();
while ( $wp_query->have_posts() ) : $wp_query->the_post();
$post_ids[] = get_the_ID() ;
endwhile;