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 9065517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:31:14+00:00 2026-06-16T16:31:14+00:00

I want to remove link from menu in perticular page. function wp_list_pages($args = ”)

  • 0

I want to remove link from menu in perticular page.

function wp_list_pages($args = '') {
$defaults = array(
    'depth' => 0, 'show_date' => '',
    'date_format' => get_option('date_format'),
    'child_of' => 0, 'exclude' => '',
    'title_li' => __('Pages'), 'echo' => 1,
    'authors' => '', 'sort_column' => 'menu_order, post_title',
    'link_before' => '', 'link_after' => '', 'walker' => '',
);

$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );

$output = '';
$current_page = 0;

// sanitize, mostly to keep spaces out
$r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);

// Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
$exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array();
$r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', $exclude_array) );

// Query pages.
$r['hierarchical'] = 0;
$pages = get_pages($r);

if ( !empty($pages) ) {
    if ( $r['title_li'] )
        $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';

    global $wp_query;
    if ( is_page() || is_attachment() || $wp_query->is_posts_page )
        $current_page = $wp_query->get_queried_object_id();
    $output .= walk_page_tree($pages, $r['depth'], $current_page, $r);

    if ( $r['title_li'] )
        $output .= '</ul></li>';
}

$output = apply_filters('wp_list_pages', $output, $r);

if ( $r['echo'] )
    echo $output;
else
    return $output;

}

Please tell me what I can do. I have searched all the previous questions concerned about this but was not able to fix the problem yet. Thanks in advance .

  • 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-16T16:31:16+00:00Added an answer on June 16, 2026 at 4:31 pm

    Just place this in your theme’s functions.php file.

    function removeParentLinks() {
    $pages = wp_list_pages('echo=0&amp;title_li=');
    $pages = explode("</li>", $pages);
    $count = 0;
    foreach($pages as $page) {
        if(strstr($page,"<ul>")) {
            $page = explode('<ul>', $page);
            $page[0] = str_replace('</a>','',$page[0]);
            $page[0] = preg_replace('/\<a(.*)\>/','',$page[0]);
            if(count($page) == 3) {
                $page[1] = str_replace('</a>','',$page[1]);
                $page[1] = preg_replace('/\<a(.*)\>/','',$page[1]);
            }
            $page = implode('<ul>', $page);
        }
        $pages[$count] = $page;
        $count++;
    }
    $pages = implode('</li>',$pages);
    echo $pages;
    

    }

    Now just replace your wp_list_pages(); function with removeParentLinks(); and away you go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to remove the link from my header using CSS so that only
I want to remove first character from link's text with jQuery. <span class=test1> +123.23
I have a django template page, and want a link from this page, containing
I want to remove a specific context menu item, appears when the Mouse down(right)
I want to remove duplicate lines from a file, without sorting the file. Example
I want to remove a key from a dictionary if it is present. I
I would appreciate some help here: What I want to do: remove &itemsperpage=10 from:
Does anyone know how to remove the renderings from a Sitecore item? I want
i need help regarding dokuwiki i want to remove versioning from wiki. any tip
I am using CKEDITOR 3.6. I want to remove an 'Anchor' plugin from the

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.