Okay
  Public Ticket #1087657
How to have current website selected on menu bar
Closed

Comments

  •  2
    aahlfeeyann started the conversation

    Hi,

    How do I make my blog post page, portfolio page and portfolio item page have that line underneath the menu to indicate that the user is on that page? See screenshot. I would like to have it activated on alfianridwan.com/portfolio , alfianridwan.com/blog and alfianridwan.com/hello-world (blog posts).

    Also, how do I add a /blog/ before the post name?

    For instance alfianridwan.com/blog/hello-world etc.

    Thanks,

    Alfian Ridwan

  •  1,558
    Laborator replied

    Hi Alfian,

    Trying to fix this issue but when disabling your plugin I got an error on your site so I will need your FTP login credentials to get it back again, and try to fix your issue. Please provide the FTP credentials.

    The /blog slug can't be added because it will be added to each post  type which means it will be /blog/portfolio/post-name too, tried different plugins to achieve this but I was not lucky, I couldn't fix it.

    Best regards,
    Laborator Team


      Documentation         Join Kalium Users Group

  •   aahlfeeyann replied privately
  • [deleted] replied

    Hi Alfian,

    I have switched the theme to default WordPress theme and the "current_page_parent" class is being applied:


    (view large version)

    Did you added some kind of code to add that class to the blog menu item?

  •  2
    aahlfeeyann replied

    Hi Arlind,

    No I didn't. I have not touched any Custom CSS class related to the menu. All I've done was that has custom CSS has to do with Visual Composer. How do I remove the class then?

    Thanks,

    Alfian

  •  2
    aahlfeeyann replied

    Also, now when I'm at the portfolio page alfianridwan.com/portfolio or the project page alfianridwan.com/portfolio/graphic the menu bar will show that its at the Blog page (see attachment). Any advice?

    Thanks,

    Alfian

  • [deleted] replied

    Hi Alfian,

    After changing the slugs for portfolio and blog the problem got fixed.

    This is not because of Kalium theme but I guess there is a plugin causing this on your side, because it was never reported from Kalium users.

    It seems like slugs /portfolio and /blog are reserved and there are being redirected when accessing in the url!

  •  2
    aahlfeeyann replied

    Hi Arlind,

    I don't understand what you are saying, right now ALL portfolio items that I have created so far is highlighted with the "Blog" menu.

    Here's some background information on how I create the portfolio items.

    1) I click on the Portfolio tab on the sidebar

    2) Add New Item

    3) Place title name, set Portfolio type to Visual Composer

    That's all. Does it got to do with the wrong show of menu link? I am guessing it has got to do with the individual project pages, not the Portfolio page itself.

    Do you have any suggestions what Plugins that may be causing this issue?

    Thanks,

    Alfian

  •  2
    aahlfeeyann replied

    Hi once again,

    After a long time of trial and error, I've realised that a portfolio item automatically falls under a Posts page. I've deactivated my alfianridwan.com/blog page on Settings > General and remove my Blog page from the dropdown (see screenshot) and the portfolio item does not have Blog menu activated on the header. However, one I activated alfianridwan.com/blog page as the Posts page, ALL the portfolio item was activated under the Blog menu.

    Is this some kind of bug? Can you please help me fix it?

    Thanks,

    Alfian

    Update:

    For the benefit of my website (as I'm planning to publicise it soon) I'm adapting the Full Screen Menu in the meantime (which does not have any effects the same as the Standard Menu, although the current_page_parent class is still applied to Blog page on a portfolio item). I hope you would be able to resolve the wrongly selected menu on the Standard Menu, as it is still my first choice for a menu. Thanks, Alfian

  •  2
    aahlfeeyann replied

    Hi,

    I finally found a workaround. I added

    <?php
    add_filter( 'nav_menu_css_class', 'je_portfolio_menu_item_classes', 10, 2 );
    /**
     * Add css classes to Portfolio CPT menu item, remove from Blog item
     *
     * Enables menu classes for CPTs.
     * Pretty fragile, as it depends on the item titles for each menu item, change as required
     * 
     * @param array  $classes CSS classes for the menu item
     * @param object $item    WP_Post object for current menu item
     * 
     * @link         http://www.josheaton.org/
     * @author       Josh Eaton <[email protected]>
     * @copyright    Copyright (c) 2013, Josh Eaton
     * @license      http://opensource.org/licenses/gpl-2.0.php GNU Public License
     */
    function je_portfolio_menu_item_classes( $classes, $item )
    {
      switch ( get_query_var('post_type') ) {
        // Only run on portfolio post type
        case 'portfolio':
          // Remove current_page_parent from Blog menu item
          if( $item->title == 'Blog' ) {
            $classes = array_diff( $classes, array( 'current_page_parent' ) );
          }
          // Add current_page_parent class to the portfolio menu item
          if ( $item->title == 'Portfolio' ) {
            $classes[] = 'current_page_parent';
          }
        break;
      }
      return $classes;
    }

    to functions.php in Themes > Kalium

    It basically removed the current_page_parent class from the Blog and added it to the Portfolio class (or in this case, 'Works').

    Although I hope that I shouldn't have done something tedious like this in the future! Took me a lot of research! Maybe you could make changes for your theme's next update!

    Thanks,

    Alfian

  • [deleted] replied

    Hi there,

    I'm very glad to hear that you found a nice solution

    Will set this ticket as solved from here.