WordPress.org

Ready to get started?Download WordPress

Forums

dynamic index page for links and categories (4 posts)

  1. harold_media
    Member
    Posted 9 years ago #

    I'm trying to put together a theme, possibly for distribution, that includes as a feature a more dynamic index page. No categories, archives, or links in the sidebar itself, but linked to in the sidebar and generated dynamically upon request. So all pages would have a navigation menu in place of a sidebar, and links, categories, etc would be generated in the main body of the page according to user request. It would be easy to slap separate pages in my root directory (links.php, etc), but that would be a touch inelegant and would break up the theme.

    So I'm thinking... should I GET a string from the URL and link conditionally to it? i.e., if $var=="links" (do links), elseif $var=="categories" (do categories), elseif $var=="archives" (do archives), else (do the existing loop for posts and comments). How would I do this? Is there a better way?

    Searching the codex for this is giving me pains. I need some specific syntax to make this work, because I'm v. much a php newbie. Any tips or links?

  2. Kafkaesqui

    Posted 9 years ago #

    See this page on the is_*() conditional functions available in 1.5:

    http://boren.nu/archives/2004/10/16/templates-and-the-is-functions/

    We have a page on this in the works for Codex.

  3. harold_media
    Member
    Posted 9 years ago #

    I'm still confused at to how I will call these functions conditionally. if I put is_page("links") on the index template, how will it know whether I want to display the links page or the index?

  4. harold_media
    Member
    Posted 9 years ago #

    Okay, the first method was a lot closer to what I wanted to do.


    <!-- links -->

    <?php if ($id == "links") { ?>
    <h2 class="sidebar-title">Links</h2>
    <?php get_links_list('-1', '', '
    ', '
    ', 0, 'name', 0, 0, -1, 0); ?>

    <!-- categories -->

    <?php } elseif($id == "categories") { ?>
    <h2 class="sidebar-title">Categories</h2>
    <?php list_cats(); ?>

    <!-- archives -->

    <?php } elseif($id == "archives") { ?>
    <h2 class="sidebar-title">Archives</h2>
    <?php get_archives(); ?>

    <?php } else { ?>

    (all the post information before the closing of the divs and the sidebar and footer includes)

    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.