Adding Anchor For Post Titles

resolved (3 posts) (2 voices)

  1. I would like to add an anchor tag that is the same as a post's title. That way I can create a button on my home page that will bring up the portfolio page and reference the proper anchor tag based on which button was clicked.

    Home page contains four fancy_boxes - under each box is a "More Info" button. These buttons link to my category page "Video" which will have four posts that are childs of this category. When I create the post, I would like to have an anchor tag assigned and echoed that is the same as the post's title.

    Example:

    I now have "Weddings" and "Events" posts. Would like to generate a < a name="Weddings" > < /a > in the title line of the Weddings post and < a name="Events" >< /a > in the title line of the Events post. Hope this makes sense.

    site: http://jak-studios.com
    category page: http://jak-studios.com/video/

    Posted 11 months ago #
  2. Ruderic
    Support

    Hello,

    What you need in the titles is an ID attribute. Then, when you create the links, they should look like this: <a href="http://website.com/videos#anchor">Link</a>

    Go to the theme folder and open the file "lib/includes/template-portfolio-full.php". In line #228 you will find this code:

    <h2 class="portfolio"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>

    Replace it with:

    <h2 class="portfolio" id="<?php echo strtolower(str_replace(' ', '', the_title('', '', false))) ?>"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>

    Now, when you create the anchor link using this pattern: http://website.com/videos#anchor

    The anchor has to be the name of the portfolio post, in lowercase and without white spaces.

    Posted 11 months ago #
  3. Excellent - works like a charm - thnx Ruderic!

    Posted 11 months ago #

Reply

You must log in to post.

Construct WordPress Theme
Construct wordpress theme
Myriad WordPress Theme
Myriad wordpress theme
Method WordPress Theme
Method wordpress theme
Fusion WordPress Theme
Fusion wordpress theme
Elegance WordPress Theme
Elegance wordpress theme
Echelon WordPress Theme
Echelon wordpress theme
Dejavu WordPress Theme
Dejavu wordpress theme
Modular WordPress Theme
Modular wordpress theme