Forums

[resolved] Change menu item from post to page (3 posts)

  1. Cbas23
    Member
    Posted 9 months ago #

    Here's my site: http://dazestate.com/. It doesn't look like much right now but I'm focusing on the menu (above the header). Right now my script that makes the menu boxes looks like this:

    <ul class="link-item-menu">
    <?php $feature_post = get_posts( 'category=6&numberposts=1' ); ?>
    <?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
    <li><h2 class="link-item-menu"><?php the_category(' '); ?></h2></li>
    <?php endforeach; ?>
    </ul>

    I would like my menu items to point to pages instead of post categories. How could I change the above code to achieve this? I tried this:

    <ul class="link-item-menu">
    <?php $page_id = 0; $page_data = get_page( $page_id ); ?>
    <li><h2 class="link-item-menu"><?php $page_data->post_title;?></h2></li>
    </ul>

    but no title showed up. Whats wrong?

  2. Cbas23
    Member
    Posted 9 months ago #

    Nvm, I fixed that with this code:

    <ul class="link-item-menu">
    <?php global $page_id; $page_id = 116;?>
    <li><h2 class="link-item-menu"><?php echo get_the_title($page_id);?></h2></li>
    </ul>

    However, the text that it creates has none of the hover or color properties that the others have. Why is this happening? And if that isn't fixable, how can I hyperlink that menu box?

  3. Cbas23
    Member
    Posted 9 months ago #

    Solved it with this code:

    <ul class="link-item-menu">
    <li><h2 class="link-item-menu"><a href="<?php echo get_page_link(116); ?>">Tutorials</a></h2></li>
    </ul>

Reply

You must log in to post.

About this Topic