List sub pages with custom field content converting image ID to URL

I ended up with this <?php //get children of page 241 and display with custom fields $args=array( ‘post_parent’ => 825, ‘post_type’ => ‘page’, ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <?php $img = wp_get_attachment_image_src( get_post_meta($post->ID, ‘product_logo’, true)); ?> <?php $alt_text_for_logo = get_post_meta($post->ID, ‘alt_text_for_logo’, true); ?> … Read more

Object of class WP_Query could not be converted to int inside shortcode

I rewrote the function based on a few other posts I have seen online and now have the following code which works without any errors. I am still open to any further suggestions on the best way to streamline this code even further it it can be. Thanks again function downloads_shortcode($atts){ extract(shortcode_atts(array( ‘download_type’ => ” … Read more

ACF Images If/else

If I understand your question correctly, I believe this is what you’re looking for: <div class=”postthumbnail”> <?php $usercrop = get_field(‘usercrop’); if ($usercrop) { $image = wp_get_attachment_image_src(get_field(‘usercrop’), ‘full’); ?> <img class=”post-thumbnail img-responsive postpic” src=”https://wordpress.stackexchange.com/questions/232716/<?php echo $image[0]; ?>” alt=”<?php echo get_the_title(get_field(‘usercrop’)) ?>” /> <?php } ?> </div> It checks the field and only displays the HTML if … Read more

Acf Pro repeater field returns null when call inside foreach

I found a Notice error in your code. You have used $description in your code. Initially you have not defined it and directly using concatenation to it. function label_text( $post_id = ” ) { $description = ”; while( have_rows(‘description’, $post_id) ): the_row(); $description .= get_sub_field(‘label’) . get_sub_field(‘text’); endwhile; return $description; }