WordPress.org

Ready to get started?Download WordPress

Forums

Can you anchor within shortcodes? (7 posts)

  1. zenkamal
    Member
    Posted 2 years ago #

    I'm using a shortcode that creates tabbed content. When I try to place a destination anchor in one tab, clicking on the anchored link in a different tab doesn't take me to the tab where the destination anchor is located.

    Anyone know if anchors are possible within shortcodes? Or if not, if there might be some type of workaround?

  2. zenkamal
    Member
    Posted 2 years ago #

    Bump. Anyone have some insight?

  3. Peter Wooster
    Member
    Posted 2 years ago #

    Yes it is possible to use shortcuts to create anchors. Here's a simple example

    function my_anchor( $atts ) {
    	return '<div id="myanchor"></div>';
    }
    add_shortcode( 'anchor', 'my_anchor' );
    
    function my_toanchor( $atts ) {
    	return '<a href="#myanchor">To the Anchor</a>';
    }
    add_shortcode( 'toanchor', 'my_toanchor' );

    The id on the div is the anchor, the hashtag goes toit.

    /peter

  4. zenkamal
    Member
    Posted 2 years ago #

    Hi Peter-- I'd like to use anchors within shortCODES not use shortCUTS to create anchors :)

    Anchors aren't working within shortcodes, so any content I place in one tab of a tab-creating shortcode cannot be anchored to another tab.

  5. Peter Wooster
    Member
    Posted 2 years ago #

    What I showed was how to create a short code that uses anchors. Are you creating the short code or just using one that someone else programmed?
    /peter

  6. zenkamal
    Member
    Posted 2 years ago #

    I'm using a shortcode that someone else programmed. It is #4 on this page, "Tabbed Content"...
    http://www.elegantthemes.com/preview/TheProfessional/shortcodes/#tabs

    When I try to use anchors in between tabs, it doesn't work.

  7. nsnadell
    Member
    Posted 1 year ago #

    Zenkamal,

    Did you ever figure this out?
    I'm using the same theme and would like to use anchors in short codes.

Topic Closed

This topic has been closed to new replies.

About this Topic