How do I add a nested conditional within an echo – to use a default image if there isn’t one in the post?

try this $second_query = new WP_Query( $args ); if ( $second_query->have_posts() ): while( $second_query->have_posts() ) : $second_query->the_post(); $attachment_id = get_field(‘image’); $size = “customfeatins”; // (thumbnail, medium, large, full or custom size) $my_image = wp_get_attachment_image_src( $attachment_id, $size ); if (!my_image !== ”){ $image = $my_image[0]; } else { $image=”http://domain/image_source/your_image.jpg”; } endif; echo ‘<article> <img src=”‘ . … Read more

Subpage Conditional

Hmm, I’ll take a crack at this. There’s a few ways to go about this. Check to see if page is a direct child, check if it is an ancestor. Something like below might work for you if (283 == $post->post_parent) { echo ‘this post has a parent of 283 so do this’; }else { … Read more

Custom Meta Box If Else Statement

You can try this: <?php // get image source: $metaboxtext3 = esc_attr( get_post_meta( get_the_ID(), ‘my_meta_box_text3’, true ) ); // get link: $metaboxtext4 = esc_attr( get_post_meta( get_the_ID(), ‘my_meta_box_text4’, true ) ); // check if the image source exists: if(strlen($metaboxtext3)>0){ ?> <a href=”https://wordpress.stackexchange.com/questions/84788/<?php echo $metaboxtext4; ?>”><img src=”<?php echo $metaboxtext3; ?>” alt=”” onerror=”this.style.display=’none'”/></a> <?php } ?>

Php markup question: php/html within conditional bit

you code may look like this <?php global $wp_query; $thepostid = $wp_query->post->ID; $postdata = get_post($thePostid, ARRAY_A); $authorid = $postdata[‘post_author’]; if ($authorid==1) { echo ‘Show nothing’; } else { ?> <div id=”author-bio”> <h3>About The Author</h3> <?php echo get_avatar( get_the_author_id() , 80 ); ?> <h4><?php the_author_posts_link(); ?></h4> <div class=”desc”><?php the_author_meta(‘description’); ?> </div> </div> <?php } ?>

Display WP Start bar on front page only

If you look at the plugin’s source, its main bits are hooked as following: add_action(‘wp_enqueue_scripts’, ‘init_wpstartbar_files’); add_action(‘admin_print_scripts’, ‘init_wpstartbar_admin’); add_action(‘wp_footer’, ‘wpstartbar_footer’,1); The easiest way to conditionally disable it would probably be along (not tested): add_action( ‘template_redirect’, function() { if( ! is_front_page() ) { remove_action(‘wp_enqueue_scripts’, ‘init_wpstartbar_files’); remove_action(‘admin_print_scripts’, ‘init_wpstartbar_admin’); remove_action(‘wp_footer’, ‘wpstartbar_footer’,1); } } );

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