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; }

Wrap group of wp query posts to parent div by date/year

This cannot be done only by querying database. Firstly, you have to iterate through all items and create array of posts grouped by dates. $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘event’, ‘meta_key’ => ‘event_date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’ ); $wpquery = new WP_Query($args); $posts = $wpquery->get_posts(); $ordered_posts = array(); foreach ($posts … Read more

Counting number of images from loop

You can get images with foreach loop but first you have to print_r($images) and then get the value of the array something like this $images[‘image’] or $images[‘src’] or $images[‘url’] etc. But first check is there any record where you are getting get_sub_field(‘image’) all images. <?php if ( $images = get_sub_field(‘image’) ) : print_r($images); foreach($images as … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)