Support

Account

Forum Replies Created

  • Version: 4.4.5.
    I use just four fields (2 text field, 1 image, 1 youtube link)

  • The latest. Back end. I can choose the image, it even shows up after choosing (I can see the thumbnail) but after saving the posts it’s gone.
    Worked for one post only.

  • Thanks, Jonathan. Yes I don’t need width and height as I have responsive design. But I thought you’d like to know the issue but maybe that’s really wp not acf problem.

  • Hi Jonathan,
    Thanks for the answer.
    In Return Value I have set Image Object.
    With your code I get the same:

    
    <img src="...-1220x814.jpg" width="640" height="427" alt="">
    

    So again good image but that width=”640″…

  • Got it working!
    There’s no need to use this $image_thumb = $icon['sizes']['full'];
    Just echo $icon and Return Value should be Image URL nor Image Object.
    Thanks again Jonathan for help.

    
    <?php
    $current_term = get_queried_object();
    $args = array(
        'parent' => $current_term->term_id,
        'orderby' => 'slug',
        'hide_empty' => false
    );
    $child_terms = get_terms( $current_term->taxonomy, $args );
    ?>
    <ul>
    	<?php foreach ($child_terms as $term) { ?>
    		<?php
    		$icon = get_field('icon', $term->taxonomy . '_' . $term->term_id);
    		?>
    	    <li>
            <h3><a href="<?php echo get_term_link( $term->name, $term->taxonomy ); ?>"><?php echo $term->name; ?></a></h3>
    		<img src="<?php echo $icon; ?>" class="icona" alt="" />
            </li>
    	<?php } ?>
    </ul>
    
  • Hi, I still can’t make it work. But I have something that maybe will help to solve the problem.
    If for Return Value (Specify the returned value on front end) I choose Image URL and there’s an image for this term than in the source I can see:
    <img src="h" class="icon" alt="" />
    If there’s no image for this term there’s nothing in src.

  • Are you sure there is an image field called “icon” on each of your terms?
    Yes, there’s.

    What have you set as the return value of this field? With your current code it should be set to “image object”.
    Yes, it’s

    There’s attachment of my settings.

    Also, you’re currently echoing the image outside of the li tag which I don’t think is what you want.. ?
    I know. It should be like:

    
    <?php
    $current_term = get_queried_object();
    $args = array(
        'parent' => $current_term->term_id,
        'orderby' => 'slug',
        'hide_empty' => false
    );
    $child_terms = get_terms( $current_term->taxonomy, $args );
    ?>
    <ul>
    	<?php foreach ($child_terms as $term) { ?>
    		<?php
    		$icon = get_field('icon', $term->taxonomy . '_' . $term->term_id);
    		$image_thumb = $icon['sizes']['full'];
    		?>
    	    <li>
            <h3><a href="<?php echo get_term_link( $term->name, $term->taxonomy ); ?>"><?php echo $term->name; ?></a></h3>
    		<img src="<?php echo $image_thumb; ?>" class="icona" alt="" />
            </li>
    	<?php } ?>
    </ul>   
    
  • Jonathan, thanks again but still I get only names of taxonomy.
    For image it’s:
    <img src="" class="icon" alt="" />

  • Hi Jonathan, thanks a lot but still can’t see the image.

  • Hi Jonathan and thanks for the answer.
    I don’t know how to create custom walker.

    So maybe I’ll try this way:

    
    $current_term = get_queried_object();
    $args = array(
        'parent' => $current_term->term_id,
        'orderby' => 'slug',
        'hide_empty' => false
    );
    $child_terms = get_terms( $current_term->taxonomy, $args );
    $icon = get_field('icon', $current_term->taxonomy . '_' . $current_term->term_id);
    $image_thumb = $icon['sizes']['full'];
    echo '<ul>';
    foreach ($child_terms as $term) {
        echo '<li><h3><a href="' . get_term_link( $term->name, $current_term->taxonomy ) . '">' . $term->name . '</h3></a></li>'; 
    	echo '<img src="'.$image_thumb.'" class="icon">';
    }
    echo '</ul>';
    

    But this code gives me only the names and not images…
    What’s wrong?

Viewing 10 posts - 1 through 10 (of 10 total)