Skip to content

Avoid duplicate query for mobile menu #40

@ghost

Description

Here is my fix:

class Aucor_Menu_Primary extends Aucor_Component {

  public static $cache;

  public static function frontend($data) {
    ?>

    <nav <?php parent::render_attributes($data['attr']); ?>>

      <?php
      if (!self::$cache) self::$cache = wp_nav_menu([
        'theme_location' => 'primary',
        'container'      => '',
        'menu_class'     => 'primary-navigation__items',
        'link_before'    => '',
        'link_after'     => '',
        'fallback_cb'    => '',
        'echo'           => false,
      ]);

      echo self::$cache;
      ?>
...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions