WordPress.org

Forums

raindrops
[resolved] Open menu link in new tab (3 posts)

  1. galapogosian
    Member
    Posted 1 year ago #

    Hi-

    I've created a custom menu so that I may link to other pages from the sidebar. In the menu structure tab, each item has a title and link field.

    Photo:

    What I need to do is make each link open in a new tab.

  2. nobita
    Member
    Theme Author

    Posted 1 year ago #

    Hi galapogosian

    Please open functions.php

    Add first line (<?php before )

    <?php
    add_filter( 'nav_menu_link_attributes','nobita_add_attribute', 10, 3 );
    
    function nobita_add_attribute( $content,$item, $args ){
    
     $content['target']= '_brank';
     return $content;
    }
    ?>

    Thank you.

  3. galapogosian
    Member
    Posted 1 year ago #

    Thank you. Worked like a charm!

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic