Automatically remove trashed pages from nav menu
Just hook the default delete_post handler for menus onto the trash action too: add_action( ‘wp_trash_post’, ‘_wp_delete_post_menu_item’ ); How simple is that!
Just hook the default delete_post handler for menus onto the trash action too: add_action( ‘wp_trash_post’, ‘_wp_delete_post_menu_item’ ); How simple is that!
I had a similar problem and here is the best solution I could come up with. The reason (I think) that private or non-published items show up in menus is that the menu items are themselves posts and have their own post_status. That means that in a situation where a page is marked private, the … Read more
I was searching for an answer for this but suddenly I got the idea and it works! In the menu settings just add the anchor link just like an html link code <a href=”#anchor” >titulo </a> So with WP is the same but only adding the anchor in the field link This will create the … Read more
Yes, I could set the menu structure, but I don’t know if the user would make this, when he creates a new page. The difference is here because I needed the hierarchy for some special adaptions I made (read the content from certain sub pages and so on …). Normally, the menu should define the … Read more
As a purely theory example, this is how I would approach the problem: $cats = get_categories(); echo ‘<ul>’; foreach($cats as $cat) { echo'<li>’.$cat->name; if($cat->parent != 0) { $subcats = get_category(‘child_of=”.$cat->cat_ID; echo “<ul>’; foreach($subcats as $subcat){ echo ‘<li>’.$subcat->name.'</li>’; } } echo ‘</li>’; } echo ‘</ul>’; I don’t expect that to work fully as I coded it … Read more
This is what i have used for checking to see if the custom field is there or not. I am sure you can use it as well. <?php $custom_field = get_post_meta($post->ID, ‘Your Custom Field Name’, true); // Checks to see if there is a value in the custom field if($custom_field != ”) { echo $custom_field; … Read more
Mostly a dupe: Why is my database import losing text widget data? Doing a search and replace on an sql dump breaks URLs in the serialized data of widgets and theme options. See the link above for better ways to change URLs when moving WP sites. Use Database Search and Replace Script in PHP | … Read more
When you register a custom post type, set the argument show_in_nav_menus to TRUE, and WordPress will create the box for you automatically. This works for custom taxonomies too. Example, requires PHP 5.4 or newer. add_action( ‘wp_loaded’, function() { $post_type=”foo”; add_action( ‘registered_post_type’, function( $registered ) use ( $post_type ) { if ( $registered !== $post_type ) … Read more
Empty your trash 🙂 Pages are not removed from the custom menus until they’ve been deleted completely. I’ve tested it right now. Creating a complex nav menu can take a very long time and the pages can be bulk deleted in a sec. I believe WordPress is just trying to save you all the trouble … Read more
The best way would be to use wp_nav_menu with a custom walker. Prerequisites: Registered theme location Menu saved to that theme location Useage Wherever you want the breadcrumbs (for theme location ‘primary’): <?php wp_nav_menu( array( ‘container’ => ‘none’, ‘theme_location’ => ‘primary’, ‘walker’=> new SH_BreadCrumbWalker, ‘items_wrap’ => ‘<div id=”breadcrumb-%1$s” class=”%2$s”>%3$s</div>’ ) ); ?> The custom walker … Read more