Forum

Forums


  • Sometimes you want to display menu without title. You can add template for it, but after some time it can get messy.  

    This solution is very often used in WP for not displaying widget title, so I willl start to use it my themes and reduced numbers of templates. 

    How to do it:

    1. add this function to theme.php  (source code is in my starter theme pack)

    /**
    * @param string $caption
    * @example []Heading 1
    * @example [Heading2]
    * @return empty string if correct syntax is used
    */
    function checkcaption( $caption )
    {
     // get rid of any leading and trailing spaces
     $title = trim( $caption );
     // check the first and last character, if [ and ] set the title to empty - this always doesn't work because admin stuff in captions
     if ( $title[0]== '[' && $title[strlen($title) - 1] == ']' ) $title = '';
     // so just put [] at the beginning of menu title
     if ( $title[0]== '[' && $title[1] == ']' ) $title = '';
     return $title;
    }

    2. just advice, but in tablestyle() you should always check if $caption is filled and only then use pre-title and after-title parts. 

    if(!empty($caption))
    {
    echo '<h2>'.$caption.'</h2>';
    }

    3. insert you title in data with []your title just for you not displayed on frontend

     

Moderator(s): Jimako, Kizi, kreossino