• Hi all.

    I have a page with a customfield. In the custom filed i have a URL for a picture.
    I would like that picture to function as a button in the menu where the page is linked.
    Im using the “new” menu function.

    I have had succes with some thing like it before.
    That was with posts. I used this:
    <?php if( get_post_meta($post -> ID, “ref_thump”, true)); ?>
    <img src=”<?php echo get_post_meta($post -> ID, “ref_thump”, true); ?>” border=”0″ width=”230″ height=”170″/>

    Hope it makes sence 🙂
    Can any one help me?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try something like this –

    $args = array(
        'echo' => false,
        'title_li' => ''
    );
    $page_name = 'News' // The name of the page to replace with an image
    $image = get_post_meta($page_id, "meta_name", true); // Where {meta_name} is the name of your meta key
    $image = <img src="'.$image.'" />
    echo str_replace($page_name, $image, wp_list_pages($args));
    Thread Starter peder77

    (@peder77)

    Hi Duck_Boy.

    Thanks for your reply.
    Sadly I cannot get it working.
    I recive the menu like this:

    <?php wp_nav_menu( array('menu' => 'left_menu', 'depth' => 1,)); ?>

    How would you combine it with you code?

    Assuming that wp_nav_menu(); accepts the echo argument, try this –

    $args = array(
        'echo' => false,
        'menu' => 'left_menu',
        'depth' => 1
    );
    $page_name = 'News' // The name of the page to replace with an image
    $image = get_post_meta($page_id, "meta_name", true); // Where {meta_name} is the name of your meta key
    $image = <img src="'.$image.'" />
    echo str_replace($page_name, $image, wp_nav_menu($args));
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Menu with customfields’ is closed to new replies.