• Hello

    I’m attempting to alter the wp_list_pages function to output not only the page titles as links but to include thumbnails from each of the pages custom fields.

    I’ve tracked down the code to the classes.php page and have amended the code to include an image within the li …

    $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . esc_attr(apply_filters('the_title', $page->post_title)) . '"><img src="' . get_post_meta($post->ID, "Thumbnail", true) . '">' . $link_before . apply_filters('the_title', $page->post_title) . $link_after . '</a>';

    Currently it outputs this source code for each li…

    <li class="page_item page-item-57"><a href="https://localhost/mysite/page_id=57" title="extra article"><img src="">extra article</a></li>

    As you can see the image src is blank.

    Could anyone please help me to get the syntax right? My php is rusty at best.

    Thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter formica

    (@formica)

    Anyone?

    Why oh why are you editting core WordPress files?

    There’s no need to do that.. Just modify the results from the call to the function using echo=0 , which just returns the data, so you can do any number of your own things with the results, without the need to modify the function directly..

    Thread Starter formica

    (@formica)

    Phew Thanks for replying,

    Sorry as I said my php is rusty, so not sure what you mean. In the sidebar.php i’m using…

    <?php wp_list_pages ('child_of=31&sort_column=post_title&title_li='); ?>

    to display my list of child pages, do you mean leave claases.php alone and alter this using echo=0 somehow to display the custom fields thumbs?

    Any futher help would be greatly appreciated t310s, I’m really struggling here.

    Sorry you might actually be stuck using the method you originally started with, it turns out the echo parameter in wp_list_pages is pretty useless for anything but placing inside conditional statements.

    There are some alternative functions about though that will mean you won’t need to touch the core files…

    I’ve seen them in various themes, usually called wp_list_pages2, have a google around and you should be able to dig one up. Build your own function rather then modifying core files.

    Thread Starter formica

    (@formica)

    Thanks for replying and poiinting me in the right direction. I’m pulling my hair out with what seems like a simple idea.

    If i have any luck i’ll post it, I’ve seen a few people with the same issue.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wp_list_pages syntax question’ is closed to new replies.