Bioran Posted June 22, 2010 Share Posted June 22, 2010 Hey folks, how would you turn sub-titles (<h3>, <h4> etc.) into permalinks on WordPress? Link to comment Share on other sites More sharing options...
0 Cupcakes Posted June 23, 2010 Share Posted June 23, 2010 <?php the_permalink() ?> That's what you use to insert a permalink in for a post/page. How you style it (eg: h1, h2, h3) is all up to you. Is that what you needed to know? Link to comment Share on other sites More sharing options...
0 Bioran Posted June 29, 2010 Author Share Posted June 29, 2010 What I mean is, I have a WP post and in it, I have titles for different sections. How can I link to these sections? (i.e. www.websiteurl.com/post-name#title) Link to comment Share on other sites More sharing options...
0 Lost_Shadows Posted June 29, 2010 Share Posted June 29, 2010 As far as I know, you cannot permalink to a section of a post, there is only one permalink for the entire post. Link to comment Share on other sites More sharing options...
0 +Dick Montage Subscriber² Posted June 29, 2010 Subscriber² Share Posted June 29, 2010 <?php the_permalink() ?>#sectionTitle <h2 title="sectionTitle">asdasdasd</h2> ? Link to comment Share on other sites More sharing options...
0 Cupcakes Posted June 29, 2010 Share Posted June 29, 2010 <?php the_permalink() ?>#sectionTitle <h2 title="sectionTitle">asdasdasd</h2> ? No. Permalinks are for post/page titles only. If you need an anchor point, the only thing you can do is just create an anchor in the post section while you're writing it up. Not only that but in order to run PHP by adding it in the content-editor, you'd need to run a plugin like PHPExec. No PHP will run as is, it'll just show up as plaintext. OP, if you need more than one page per page, then you might want to use "Multiple Pages." Although that will literally put each on its own page.. In a post/page use: <!--nextpage--> In you post/page template: <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> http://codex.wordpress.org/Styling_Page-Links Link to comment Share on other sites More sharing options...
0 Calculator Posted June 29, 2010 Share Posted June 29, 2010 If you're okay with getting your hands dirty and editing your post content as HTML, you can make anchors to specific sections in your page using the ID attribute. <h3 id="mysection">My Section</h3> Content goes here... Then, to jump to that section from the same post, simply create an anchor with the address set to "#mysection" (and open in same window). Or, in HTML: <a href="#mysection">Jump to my section</a> You could do the same with plugins, I use TinyMCE Advanced's Anchor button which wraps text in <a name="[anchor name]">...</a> tags. This behaves exactly the same as using an ID, but uses an extra <a> tag. Link to comment Share on other sites More sharing options...
0 Bioran Posted July 1, 2010 Author Share Posted July 1, 2010 @Cupcakes - Interesting. Not the solution I'm looking for, but it'd certainly be useful for other things. @Calculator - That seems like what I'm looking for. :) However, let's say I now want to link to that section off-site. How would that work, then? Would it be something like what I mentioned above? (www.websiteurl.com/post-name#title) Would it work at all? Link to comment Share on other sites More sharing options...
0 Cupcakes Posted July 1, 2010 Share Posted July 1, 2010 @Cupcakes - Interesting. Not the solution I'm looking for, but it'd certainly be useful for other things. @Calculator - That seems like what I'm looking for. :) However, let's say I now want to link to that section off-site. How would that work, then? Would it be something like what I mentioned above? (www.websiteurl.com/post-name#title) Would it work at all? If you want to link "off-site" then you would literally just link that website. You can't use an URL anchor that's for a website that.. doesn't already have that anchor created. Meaning that if my blog post is setup on domainblog.com/post-url#first and I want to link to domainforum.com/blog-post and that /blog-post has no anchors defined.. You can't create an anchor. If you want to link a section offsite that has nothing to do with anchors (eg: domainblog.com/post-url#first). That's a basic link. Resource: HTML Links - The name Attribute Link to comment Share on other sites More sharing options...
Question
Bioran
Hey folks, how would you turn sub-titles (<h3>, <h4> etc.) into permalinks on WordPress?
Link to comment
Share on other sites
8 answers to this question
Recommended Posts