WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. galapogosian
    Member
    Posted 6 months 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 6 months 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 6 months ago #

    Thank you. Worked like a charm!

Reply

You must log in to post.

About this Theme

About this Topic