Title: Exclude sticky post from menu
Last modified: August 21, 2016

---

# Exclude sticky post from menu

 *  Resolved [rgbcraft](https://wordpress.org/support/users/rgbcraft/)
 * (@rgbcraft)
 * [12 years ago](https://wordpress.org/support/topic/exclude-sticky-post-from-menu/)
 * Thank you so much for the plug in. It works beautifully.
 * I need a way to exclude a sticky post from being listed in the menu. I can follow
   the logic of php but writing it is currently above my skill level. Would you 
   be able to provide a code snippet and location to add the ignore_sticky_posts
   parameter?
 * Any direction you provide is appreciated.
 * [https://wordpress.org/plugins/category-posts-in-custom-menu/](https://wordpress.org/plugins/category-posts-in-custom-menu/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Diana van de Laarschot](https://wordpress.org/support/users/anaid/)
 * (@anaid)
 * [12 years ago](https://wordpress.org/support/topic/exclude-sticky-post-from-menu/#post-4828535)
 * Hi rgbcraft,
 * thanks for your response. You could look at the is_sticky() function in WordPress(
   [http://codex.wordpress.org/Function_Reference/is_sticky](http://codex.wordpress.org/Function_Reference/is_sticky))
 * I haven’t tried it, but in the foreach loop that iterates over the posts, on 
   the first line inside the loop you could try:
 * if (is_sticky(post->ID)) { continue; }
 * Again, I haven’t tried it, but something like this might work. I’ll think about
   adding support for your request in a way that doesn’t clutter the user interface.
   I don’t want to add too many checkboxes and stuff, I hope you’ll understand.
 * Kind regards,
    Diana
 *  Thread Starter [rgbcraft](https://wordpress.org/support/users/rgbcraft/)
 * (@rgbcraft)
 * [12 years ago](https://wordpress.org/support/topic/exclude-sticky-post-from-menu/#post-4828554)
 * I may have the wrong place, but I tried your suggestion and the menu disappeared
   altogether.
 *     ```
       /*
       	* Build the menu structure for display: Augment taxonomies (category, tags or custom taxonomies) that have been marked as such, by their posts. Optionally: remove original menu item.
       	*/
       	function cpcm_replace_taxonomy_by_posts( $sorted_menu_items, $args ) {
       		$result = array();
       		$inc = 0;
   
       		foreach ( (array) $sorted_menu_items as $key => $menu_item ) {
       		if ( is_sticky()) {continue ;}
       			// Augment taxonomy object with a list of its posts: Append posts to $result
       			// Optional: Remove the taxonomy object/original menu item itself.
       ```
   
 *  Plugin Author [Diana van de Laarschot](https://wordpress.org/support/users/anaid/)
 * (@anaid)
 * [12 years ago](https://wordpress.org/support/topic/exclude-sticky-post-from-menu/#post-4828588)
 * Hi rgbcraft,
 * 1. That’s not the foreach loop that iterates over the posts
    2. You haven’t copied
   the line I gave you properly
 * Haven’t got the time to copy the exact code for you right now, I’ll check back
   in later.
 * Kind regards,
    Diana
 *  Plugin Author [Diana van de Laarschot](https://wordpress.org/support/users/anaid/)
 * (@anaid)
 * [12 years ago](https://wordpress.org/support/topic/exclude-sticky-post-from-menu/#post-4828620)
 * Hi rgbcraft,
 * I’ve applied the fix I proposed myself. Firstly, I apologize for omitting the
   dollar sign in the $post variable.
 * Here’s what you should do. Find the line `foreach( (array) $posts as $pkey =>
   $post ) {`
 * Right beneath that, but above the comment `// Decorate the posts ...`, add the
   line `if (is_sticky($post->ID)) { continue; }`
 * The result should be:
    ` foreach( (array) $posts as $pkey => $post ) { if (is_sticky(
   $post->ID)) { continue; }
 * // Decorate the posts with the required data for a menu-item.
    $post = wp_setup_nav_menu_item(
   $post );
 * I may add some support for stickies later, but not right now.
 *  Thread Starter [rgbcraft](https://wordpress.org/support/users/rgbcraft/)
 * (@rgbcraft)
 * [12 years ago](https://wordpress.org/support/topic/exclude-sticky-post-from-menu/#post-4828621)
 * Thank you so much!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Exclude sticky post from menu’ is closed to new replies.

 * ![](https://ps.w.org/category-posts-in-custom-menu/assets/icon-128x128.png?rev
   =2539336)
 * [Category Posts in Custom Menu](https://wordpress.org/plugins/category-posts-in-custom-menu/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/category-posts-in-custom-menu/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/category-posts-in-custom-menu/)
 * [Active Topics](https://wordpress.org/support/plugin/category-posts-in-custom-menu/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/category-posts-in-custom-menu/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/category-posts-in-custom-menu/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [rgbcraft](https://wordpress.org/support/users/rgbcraft/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/exclude-sticky-post-from-menu/#post-4828621)
 * Status: resolved