WordPress.org

Ready to get started?Download WordPress

Forums

Nav menu nog showing up as taxonomy (1 post)

  1. michiels
    Member
    Posted 1 year ago #

    Hello all,

    I am trying to use my nav menu as a taxonomy. What I basically want to do is display all the pages from a nav_menu as an a "category" or "archive" in the loop. To illustrate:

    if ($query->is_main_query()) {
        $query->set('post_type', 'page');
        $query->set('tax_query', array('nav_menu' => 'primary'));
      }

    However, this seems to return no results.

    When I list all the taxonomies by using get_taxonomies() there is a "nav_menu" key in the returned array.

    array(5) { ["category"]=> string(8) "category" ["post_tag"]=> string(8) "post_tag" ["nav_menu"]=> string(8) "nav_menu" ["link_category"]=> string(13) "link_category" ["post_format"]=> string(11) "post_format" }

    But when I grab all the terms associated to a page that I put in the "primary" nav menu I get empty results:

    wp_get_post_terms($post->ID); -> array(0) {}

    Are nav_menus supported taxonomies?

Topic Closed

This topic has been closed to new replies.

About this Topic