WordPress.org

Ready to get started?Download WordPress

Forums

[Hack: Custom active links] Help on a theory of custom active links (1 post)

  1. incite
    Member
    Posted 5 years ago #

    I have made my own menu not using wp_list_pages but instead using my own query and listing posts in a category for each menu item. Ive done this because of the menu effect i have and the way i am using WordPress to post. There is a reasonable explanation for doing things this way i just dont want the attention to be taken away from the solution i actually need.

    A custom menu i use currently uses a query:

    <?php $my_query = new WP_Query('category_name=design'); ?>
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <ul><li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li></ul>
    
    <?php endwhile;?>

    Once the link is clicked it takes me to the post using the standard single.php. In this single.php i have the following:

    <div class="item entry" id="post-<?php the_ID(); ?>">
    <div class="itemhead">
    <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    ETC ETC ETC

    This displays the contents of the post.

    Obviously the current_item in my css will not work for showing the user which link is active. And other work arounds fail for my theme. Also doing specific coding in CSS will not work as the item menus will always change.

    What i need is the following:

    To create a query/script to query the <div id="post-<?php the_ID(); ?>">(OR PERMALINK/TITLE WHICHEVER SUITS)

    Then if that id/permalink/title matches the one in the menu list an echo "on"/"off" command can be sent to the "a" tag and therefore making it easier to format selected/deselected menu items.

Topic Closed

This topic has been closed to new replies.

About this Topic