Skip to main content
added 69 characters in body
Source Link
bigpotato
  • 335
  • 2
  • 6
  • 16

I'm using a theme and I noticed that it dynamically displays an array of the categories in the menu:

enter image description here

I need the same list of categories but within different HTML tags for my footer. Currently this is what I have in my footer:

enter image description here

footer.php:

<?php
      $categories = get_categories();
      foreach($categories as $category) {
        echo '<a href="' . get_category_link($category->term_id) . '">' . $category->name . '</a>';
      }
?>

As you can see, it's not in the same order as the one in the menu.

I tried to use that as a hint to how I would loop through the categories. However, when I try to find the template for the header, I notice that it just points to this and I don't see any of the PHP / HTML:

    <nav class="main-navigation">

      <?php
        wp_nav_menu( array(
          'theme_location' => 'header-menu',
          'fallback_cb' => 'false',
        ) );
      ?>

    </nav><!-- /.main-navigation -->

I tried looking everywhere for a header-menu.php file but it doesn't seem to exist, possibly because it's coming from the theme..?

register_nav_menus( array(
  'header-menu' => esc_html__( 'Header', 'neori' ),
) );

Here's a pic of what I want:

enter image description here

I'm using a theme and I noticed that it dynamically displays an array of the categories in the menu:

enter image description here

I need the same list of categories but within different HTML tags for my footer. Currently this is what I have in my footer:

enter image description here

footer.php:

<?php
      $categories = get_categories();
      foreach($categories as $category) {
        echo '<a href="' . get_category_link($category->term_id) . '">' . $category->name . '</a>';
      }
?>

As you can see, it's not in the same order as the one in the menu.

I tried to use that as a hint to how I would loop through the categories. However, when I try to find the template for the header, I notice that it just points to this and I don't see any of the PHP / HTML:

    <nav class="main-navigation">

      <?php
        wp_nav_menu( array(
          'theme_location' => 'header-menu',
          'fallback_cb' => 'false',
        ) );
      ?>

    </nav><!-- /.main-navigation -->

I tried looking everywhere for a header-menu.php file but it doesn't seem to exist, possibly because it's coming from the theme..?

register_nav_menus( array(
  'header-menu' => esc_html__( 'Header', 'neori' ),
) );

I'm using a theme and I noticed that it dynamically displays an array of the categories in the menu:

enter image description here

I need the same list of categories but within different HTML tags for my footer. Currently this is what I have in my footer:

enter image description here

footer.php:

<?php
      $categories = get_categories();
      foreach($categories as $category) {
        echo '<a href="' . get_category_link($category->term_id) . '">' . $category->name . '</a>';
      }
?>

As you can see, it's not in the same order as the one in the menu.

I tried to use that as a hint to how I would loop through the categories. However, when I try to find the template for the header, I notice that it just points to this and I don't see any of the PHP / HTML:

    <nav class="main-navigation">

      <?php
        wp_nav_menu( array(
          'theme_location' => 'header-menu',
          'fallback_cb' => 'false',
        ) );
      ?>

    </nav><!-- /.main-navigation -->

I tried looking everywhere for a header-menu.php file but it doesn't seem to exist, possibly because it's coming from the theme..?

register_nav_menus( array(
  'header-menu' => esc_html__( 'Header', 'neori' ),
) );

Here's a pic of what I want:

enter image description here

Source Link
bigpotato
  • 335
  • 2
  • 6
  • 16

How to order get_categories() in the same order as the menu?

I'm using a theme and I noticed that it dynamically displays an array of the categories in the menu:

enter image description here

I need the same list of categories but within different HTML tags for my footer. Currently this is what I have in my footer:

enter image description here

footer.php:

<?php
      $categories = get_categories();
      foreach($categories as $category) {
        echo '<a href="' . get_category_link($category->term_id) . '">' . $category->name . '</a>';
      }
?>

As you can see, it's not in the same order as the one in the menu.

I tried to use that as a hint to how I would loop through the categories. However, when I try to find the template for the header, I notice that it just points to this and I don't see any of the PHP / HTML:

    <nav class="main-navigation">

      <?php
        wp_nav_menu( array(
          'theme_location' => 'header-menu',
          'fallback_cb' => 'false',
        ) );
      ?>

    </nav><!-- /.main-navigation -->

I tried looking everywhere for a header-menu.php file but it doesn't seem to exist, possibly because it's coming from the theme..?

register_nav_menus( array(
  'header-menu' => esc_html__( 'Header', 'neori' ),
) );