Dynamic Anchor Links - Single Page Site (4 posts)

  1. Anthony Hamill
    Posted 5 years ago #

    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.


  2. wood4283
    Posted 5 years ago #

    I'm looking for the same thing. Any luck find a solution?

  3. Anthony Hamill
    Posted 4 years ago #

    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.

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

    Hopefully this helps.
    - Anthony

  4. Christopher McMahon
    Posted 4 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic