• Resolved Cbas23

    (@cbas23)


    Here’s my site: https://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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Cbas23

    (@cbas23)

    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?

    Thread Starter Cbas23

    (@cbas23)

    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>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change menu item from post to page’ is closed to new replies.