Title: Using strpos() for Menu Sections
Last modified: August 22, 2016

---

# Using strpos() for Menu Sections

 *  Resolved [JamesEMCS](https://wordpress.org/support/users/jamesemcs/)
 * (@jamesemcs)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/using-strpos-for-menu-sections/)
 * Hi. I’m running a very complex operation with this plugin, so I apologise in 
   advance.
 * Basically my Menus sections contain dates which I don’t want to be displayed 
   to the public. I was planning on using PHPs strpos() function to remove the dates
   from the section headers in a format like this;
 *     ```
       if strpos($this->menu_section, "Starters") {
       	echo substr($this->menu_section, -8);
       }
       elseif strpos($this->menu_section, "Main") {
       	echo substr($this->menu_section, -4);
       }
       elseif strpos($this->menu_section, "Dessert") {
       	echo substr($this->menu_section, -7)
       }
       ```
   
 * So for example “26th April 31st May 14th June 20th September 11th October Main”
   would be displayed as just “Main”
 * However I’m not sure where in the plugin the menu section headers are printed/
   echoed. Could anybody help guide me on this one?
 * [https://wordpress.org/plugins/food-and-drink-menu/](https://wordpress.org/plugins/food-and-drink-menu/)

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

 *  [NateWr](https://wordpress.org/support/users/natewr/)
 * (@natewr)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/using-strpos-for-menu-sections/#post-5892620)
 * Hi James,
 * Have you seen the [templating system](http://themeofthecrop.com/about/news/) 
   for Food and Drink Menu? That might be the best place to accomplish what you 
   want.
 * Although I do wonder why the section names have long strings of dates in them.
   If you tell me a little more about what you’re trying to accomplish, I may be
   able to help you find a better solution.
 *  Thread Starter [JamesEMCS](https://wordpress.org/support/users/jamesemcs/)
 * (@jamesemcs)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/using-strpos-for-menu-sections/#post-5892627)
 * Hi Nate,
 * I haven’t seen the templating system and the link you’ve provided takes me to
   a news page. I’m not sure where to go from there.
 * As I said; a complex system. The Menus I’m creating are separated into dates 
   for when they’ll be available. I’m after 3 sections per menu (Starters, Main &
   Dessert). The long string of dates is so I can add the sections to the correct
   menu because if I have just one section with all the different dated menus in;
   they wont be broken down into the correct dates.
    Hope that makes sense!
 *  [NateWr](https://wordpress.org/support/users/natewr/)
 * (@natewr)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/using-strpos-for-menu-sections/#post-5892633)
 * Hi James,
 * Sorry, copy-paste error. Here’s the link to the [quick introduction](http://themeofthecrop.com/2014/01/28/customize-restaurant-menu-templates/)
   to the templating system. You should be able to throw your code into a function
   and pass the Menu Section title through that function before printing it in the
   template.
 * From what I understand, you only need the dates attached to Menu Sections so 
   that you can more easily select them in the Menu Layout and when assigning them
   to Menu Items. The backend is not quite as easily adaptable as the frontend layout,
   so I don’t have a good solution for you that wouldn’t involve a significant amount
   of coding.
 *  Thread Starter [JamesEMCS](https://wordpress.org/support/users/jamesemcs/)
 * (@jamesemcs)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/using-strpos-for-menu-sections/#post-5892675)
 * Hi Nate.
 * Thank you for the link. It does help a lot meaning that updates wont break my
   changes. And so I can find where the <h3> titles are being echoed.
 * So my function (in menu-section.php) looks like this;
 *     ```
       if (strpos($this->title, "Starters") !== false) {
       	echo substr($this->title, -8);
       }
       elseif (strpos($this->title, "Main") !== false) {
       	echo substr($this->title, -4);
       }
       elseif (strpos($this->title, "Dessert") !== flase) {
       	echo substr($this->title, -7);
       }
       ```
   
 * And displays exactly how I expected.
 * Thank you for your help!
 *  [NateWr](https://wordpress.org/support/users/natewr/)
 * (@natewr)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/using-strpos-for-menu-sections/#post-5892679)
 * Great! Glad it’s working for you.

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

The topic ‘Using strpos() for Menu Sections’ is closed to new replies.

 * ![](https://ps.w.org/food-and-drink-menu/assets/icon-128x128.png?rev=2205559)
 * [Five Star Restaurant Menu and Food Ordering](https://wordpress.org/plugins/food-and-drink-menu/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/food-and-drink-menu/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/food-and-drink-menu/)
 * [Active Topics](https://wordpress.org/support/plugin/food-and-drink-menu/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/food-and-drink-menu/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/food-and-drink-menu/reviews/)

## Tags

 * [display](https://wordpress.org/support/topic-tag/display/)
 * [hide](https://wordpress.org/support/topic-tag/hide/)
 * [menu](https://wordpress.org/support/topic-tag/menu/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [section](https://wordpress.org/support/topic-tag/section/)
 * [strpos](https://wordpress.org/support/topic-tag/strpos/)

 * 5 replies
 * 2 participants
 * Last reply from: [NateWr](https://wordpress.org/support/users/natewr/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/using-strpos-for-menu-sections/#post-5892679)
 * Status: resolved