Support » Fixing WordPress » Dynamic Anchor Links – Single Page Site

  • Anthony Hamill

    (@pardnerogmailcom)


    Hello all,
    I’m trying to create a theme for a single page wordpress theme, very similar to this – http://themetrust.com/demos/solo/

    How would you go about creating the nav for this? I was thinking that since I plan on creating each section of the site separately I could just build the nav dynamically, but can’t seem to figure out how to make the nav links just be anchor tags…

    Also, if anyone has any good direction on how to go about building this type of site, I’d love to hear your suggestions.

    Thanks,
    Anthony

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m looking for the same thing. Any luck find a solution?

    In order to create the list of anchor tags dynamically, I used wordpress’s ‘get_pages’ function. Here is a copy of the code I used in order to achieve an un-ordered list of the pages in my site.

    <ul>
    <?php $args = array('sort_column' => 'menu_order');
    $pages = get_pages($args);
    foreach ($pages as $pagg) : setup_postdata($post);?>
    <li><a href="#<?php echo(get_the_title($pagg->ID));?>"class="panel"><?php echo(get_the_title($pagg->ID));?></a></li>
    <?php endforeach; ?>
    </ul>

    Hopefully this helps.
    – Anthony

    An SEO friendly/human readable update to Anthony’s code above would be to replace the page ID with the page slug.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Dynamic Anchor Links – Single Page Site’ is closed to new replies.