Support

Account

Home Forums Front-end Issues Display Image URL on Archive.php do'nt Work Reply To: Display Image URL on Archive.php do'nt Work

  • So, the field group and the field is edited when when editing a category.

    Do you also have this field on tag pages?

    Do you also have the images set up on the author page?

    If not, what image do you want to show on the tag and author archive pages?

    What image will you display on a date archive page? (year, month, day)

    You’re editing a generic archive page that can show any of these things.

    For all of the other types of pages should it show the image from the first post that’s displayed?

    As I said in my first post, the link I referenced above gives information on how to get values from different places.

    For a category or tag: the_field('field_name', $taxonomy.'_'.$term_id)

    For an author: the_field('field_name1', 'user_'.$user_id);

    I could tell you how to show the image on a category page, but that would not show an image for all of the other cases that can be displayed by your archive template. For example, this will work on a category page but would not work on an author or date archive page.

    
    $post_id = 0;
    $queried_object = get_queried_object();
    if (isset($queried_object->term_id)) {
      $post_id = $queried_object->taxonomy.'_'.$queried_object->term_id;
    }
    ?>
    <div class="page-header"
         style="background-image:url(<?php 
                the_field('titelbild2', $post_id); ?>); 
                background-repeat: no-repeat;
                background-size:cover; 
                background-position:center;">