Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7742233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:13:45+00:00 2026-06-01T09:13:45+00:00

I am working on a WordPress-Design and i want to creat a Custom Menu.

  • 0

I am working on a WordPress-Design and i want to creat a Custom Menu.

$items = wp_get_nav_menu_items('Menu', array(
    'order'                  => 'ASC',
    'orderby'                => 'menu_order',
    'post_type'              => 'nav_menu_item',
    'post_status'            => 'publish',
    'output'                 => ARRAY_A,
    'output_key'             => 'menu_order',
    'nopaging'               => true,
    'update_post_term_cache' => false));
echo '<pre>'; print_r($items); echo '</pre>'; 
foreach($items as $item){
    echo '<div class="menu_entry"><a href="'.$item->url.'">'.$item->title.'</a></div>';
}

The problem is, i need the “current-page”-Class, which is WordPress creating – in the Standard Menu.

Any Ideas how to add this class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:13:45+00:00Added an answer on June 1, 2026 at 9:13 am

    You can do a compare on the current page / cat etc ID against the menu items object_id which is the ID of the page / category etc its linked to.

    Something like (untested);

    global $post;
    $thePostID = $post->ID;
    foreach($items as $item){
    
        if($thePostID === $item->object_id) {
            echo '<div class="menu_entry"><a href="'.$item->url.'" class="current-menu-item">'.$item->title.'</a></div>';
        }else{
            echo '<div class="menu_entry"><a href="'.$item->url.'">'.$item->title.'</a></div>';
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with wordpress.com along with the custom design upgrade to be able to
I'm working on WordPress theme which has some custom functionality which includes the ability
I'm working on a wordpress site, customizing the menu. I'm no php whiz, and
I'm working on a WordPress site that uses a dynamically generated menu system which
So I have been working with Wordpress 3.x and trying to build a custom
WP_Query('orderby=post_date') is not working with wordpress. how do I sort my posts in descending
I'm working on a WordPress CMS site and I want to add my own
I have just installed a custom WordPress theme (this is my first time working
I am working on a wordpress platform, while generating a mysql query I want
I am working on a Wordpress plugin and I need to pass PHP array

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.