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

Help with if else statement for separating content from image attachment

Technically, this should work: <!–display image–> <div class=”featured-image”> <?php $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => null, ‘post_parent’ => $post->ID ); $attachments = get_posts( $args ); if ( $attachments ) { foreach ( $attachments as $attachment ) { echo wp_get_attachment_image( $attachment->ID, ‘full’ ); } } ?> </div> <?php $content = preg_replace(‘/<img[^>]+./’,”,get_the_content()); … Read more