• 0

Titles and Permalinks


Question

8 answers to this question

Recommended Posts

  • 0

<?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

  • 0

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

  • 0

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

  • 0

<?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:

&lt;!--nextpage--&gt;

In you post/page template:

&lt;?php wp_link_pages(array('before' =&gt; '&lt;p&gt;&lt;strong&gt;Pages:&lt;/strong&gt; ', 'after' =&gt; '&lt;/p&gt;', 'next_or_number' =&gt; 'number')); ?&gt;

http://codex.wordpress.org/Styling_Page-Links

Link to comment
Share on other sites

  • 0

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.

&lt;h3 id="mysection"&gt;My Section&lt;/h3&gt;
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:

&lt;a href="#mysection"&gt;Jump to my section&lt;/a&gt;

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

  • 0

@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

  • 0

@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

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.