2

I am working with a CPT that is using ACF fields to manage content and the hero image.

With the new Archive page template, I wish to have featured images alongside the content. Earlier we did not use images on archive pages.

Considering the fact that there are a lot of posts, I was thinking of a way to assign all the images in the custom field, as featured images for the same post. I need the images to be at both the places.

Can wp-cli do this? If yes can anyone guide me how?

Currently, the archive page template is like this.(this is not the complete archive, just a snippet from it, let me know if I need to share the whole file.)

<div class="row item whitepaper-li">
            <div class="col-md-12">
              <!-- check if the post has thumbnail -->
            <?php if ( has_post_thumbnail($type->id)) {?>

              <div class="col-xs-3">
                <a href="<?php the_permalink($type->id); ?>" title="<?php echo esc_attr($type->title); ?>" >
                    <?php echo get_the_post_thumbnail($type->id,'thumbnail', array( 'class' => 'whitepapers-featuredimage' )); ?>
                  </a>
                </div>
              <!-- if no thumbnail attached, use default -->
              <?php  } else { ?>

                <div class="col-xs-3">
                  <a href="<?php the_permalink($type->id); ?>" title="<?php echo esc_attr($type->title);?>" >
                        <img class="whitepapers-def-thumb" src="<?php echo esc_url(getPostTypeIcon( 'whitepapers' )); ?>"/>
                  </a>
                    </div>

              <?php } ?>
                <div class="col-xs-9">
                  <h2 class="h3">

                                <a href="<?php the_permalink($type->id) ?>"><?php echo esc_attr($type->title); ?>
                                </a>
                            </h2>


                        <p>
                            <?php echo esc_html($type->excerpt); ?> <a href="<?php the_permalink($type->id)?>">Continued</a>
                        </p>
            </div>
                        <hr>
                        <?php if( array_key_exists('topics', $type->tags) ) foreach( $type->tags['topics'] as $topic ) { ?>
                        <input type="hidden" value="<?php echo $topic->slug; ?>" name="<?php echo $topic->name; ?>" />
                        <?php } ?>
                </div> <!-- end col-11 -->
            </div>
            <?php } ?>
        </div><!-- end content-wrap -->

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.