WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [WordPress Post Tabs]: Problems with Anchors (2 posts)

  1. wotto
    Member
    Posted 1 year ago #

    hello, i am trying to link from a button on my page to a specific tab on that page. i can build the anchor link no problem, (ex: #tabs-1149-0-5) and insert it into the following html code

    p align="center">
    	<form action="#tabs-<?php echo $postid; ?>-0-<?php echo $tabnum?>">
    		<div>
    			<button type="submit">Buy Now</button>
    		</div>
    	</form>
    </p>

    and it only kind of works. When i click it the first time it takes me to the correct tab, but after that the button does nothing. if i switch tabs than click the button, it just stays on the new tab. The only time anything happens is if i reclick on the desired tab, then click the button, it will reload that same tab. any suggestions, including other ways to do it are greatly appreciated!

    p.s. i know typically this would be solved with js but unfortunately im limited to php (The button is part of a sidebar widget and i am using PHP Code Widget Plugin, which only handle php, html and plain text)

  2. wotto
    Member
    Posted 1 year ago #

    this always seems to happen...ten minutes after i post a question to a forum i figure it out, below code solved my problem.

    <p align="center">
    	<form action="<?php echo $PHP_SELF; ?>#tabs-<?php echo $postid; ?>-0-<?php echo $tabnum?>" method="post">
    		<div>
    			<button type="submit">Buy Now</button>
    		</div>
    	</form>
    </p>

    closing thread

Topic Closed

This topic has been closed to new replies.

About this Topic