• Hi

    I would be very grateful if someone could tell me where I am going wrong with trying to display custom field content of a PAGE in the side bar, no matter what page or post the visitor is on.

    I have been able to get it to display on the side when on the page itself but as soon as I go to another page it disappears.

    Here is what I am using:

    FUNCTION

    ‘<?php
    function get_custom_field($key, $echo = FALSE) {
    global $post;
    $custom_field = get_post_meta($post->ID, $key, true);
    if ($echo == FALSE) return $custom_field;
    echo $custom_field;
    }
    ?>’

    PHP

    ‘<h2 class=”feature_whiteRight_img_content”>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php get_custom_field(‘dbt2_text’, TRUE); ?></h2>

    <img src=”<?php get_custom_field(‘dbt2_img’, TRUE); ?>” /> ‘

    I have tried a number of other options – all with the same result where the information just displays when on the page containing the custom fields.

    Below is a link to the website page in question. The content is the little white pullout box to the right at the top of the sidebar with the pilot flying.

    https://tbminsurance.slicetest.co.nz/specialist-options/pilot-insurance-options/

    Thank you so much in advance. Have spent last three days trying to resolve.

Viewing 1 replies (of 1 total)
  • Thread Starter SliceCreative

    (@slicecreative)

    I have just realised that the code above returns all custom field data for each page that has it so the above code is incorrect.

    If you go to the link and it doesn’t look right it might be because I am trying a few more options.

    Any help on how to do this would be much appreciated.

Viewing 1 replies (of 1 total)
  • The topic ‘Displaying custom fields in sidebar for all pages’ is closed to new replies.