简体   繁体   中英

Bootstrap Tabs: Go to Specific Tab on different page in Wordpress

I use bootstrap to create the static site. In my home page i have a link to redirect to specific tab of another page. I use this script code, it works perfect in bootstrap static html page. Code in JS

    $(function() {
    var hash = window.location.hash;

    hash && $('ul.nav a[href="' + hash + '"]').tab('show');
});

Code in Html

<a href="tyres.html#menu7">

It will redirect page to tyre.htmil tab menu7, work perfect.

Once I move the html to themes of wordpress, this function does not work properly in php. it only redirect to the page, not on specific tab anymore.

Code i tried in php of home page of wordpress

<a href="tyres#menu7">

and

 <a href="tyres.php#menu7">

Do i need to replace Permalink name to ID? or what is right format i need to use in php? or if there is anything i need to change of my JS code?

Thanks

尝试改用这个

<a href="/tyres/#menu7" data-toggle="tab">

Try using the wordpress site_url(); function in the anchor tag like this to redirect and open the tab on destination page

<a href="<?php echo site_url(); ?>/your-page#tab-hash">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM