WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Jump Links in the Loop

[Resolved] Jump Links in the Loop

  • Hey all.

    I am currently developing a theme that has a very large header (http://wpdev.hugsformonsters.com).

    I got the idea to include a jump link in my index.php loop to take users directly to the content of the post they click on:

    <a href="<?php the_permalink() ?>/<strong>#header</strong>" rel="bookmark" title="<?php the_title_attribute(); ?>">

    I included this html on the single.php page:

    <h2>
    	<a <strong>name="header"</strong> rel="bookmark" title="<?php the_title_attribute(); ?>">
    		<?php the_title(); ?>
    	</a>
    </h2>

    The link on index.php always takes you to the correct post without incident, but it does not take you to the correct point on the page. I did some searching and was unable to find a similar case of this.

    Is there anything in WordPress that prevents the use of jump links in this manner?

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Uhh, ignore the [strong][/strong] in there. I was formatting the post here and stupidly forgot that adding bold to something in a pre tag would just show the code to make something bold ;P

    In the XHTML doctype definition, the “id” and “name” attributes are synonymous. Since you already have a DIV element with “header” as the id, and it is required to be unique, the browser may choose to ignore the name of your A element.

    “header2” would work better, for example.

    Oh snips! I didn’t realize that about id and name.

    Thanks dude!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Jump Links in the Loop’ is closed to new replies.
Skip to toolbar