Coder Social home page Coder Social logo

automattic / add-descendants-as-submenu-items Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 5.0 158 KB

WordPress plugin for dynamically adding descendants to menus.

Home Page: https://alex.blog/wordpress-plugins/add-descendants-as-submenu-items/

License: GNU General Public License v2.0

PHP 86.87% JavaScript 13.13%
wordpress wordpress-plugin

add-descendants-as-submenu-items's People

Contributors

jom avatar viper007bond avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

add-descendants-as-submenu-items's Issues

Add ability to limit menu depth

Requested in https://wordpress.org/support/topic/limit-the-grandchilden-in-the-menu/:

Is there a way to limit the menu depth, showing only: Child page / Grandchilden page ?

A previous commenter on Alex Mills' blog (2013) suggested this solution in comments.

See also Wayback Machine.

find:

case ‘post_type’:
// Using get_pages() instead of get_posts() because we want ALL descendants
$children = get_pages( array(
‘child_of’ => $item->object_id,
‘post_type’ => $item->object,
‘sort_column’ => ‘menu_order, post_title’,
) );


and change to:

case ‘post_type’:
// Using get_pages() instead of get_posts() because we want ALL descendants
/* Edit by gbmhunter to remove grandchildren. Removed the following
$children = get_pages( array(
‘child_of’ => $item->object_id,
‘post_type’ => $item->object,
‘sort_column’ => ‘menu_order, post_title’,
) );
*/
/* And added this */
$children = get_pages(‘child_of=’.$item->object_id.’&parent=’.$item->object_id);

but it doesn't currently appear to work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.