Display Latest Post on a Page Conditionally

Possibly you could wrap the code on the vendor’s page in a comparison. So if the vendor’s name is the Title of their page, and the newest post has a meta field that hold’s the vendor’s name, it could look like this: $my_most_recent_post = get_posts( ‘numberposts=1’ ); $my_most_recent_post_id = $my_most_recent_post[0]->ID; // Get the featured item’s … Read more

Run a php function if a predefined page is visited

Have a look at the is_page() conditional tag and at conditional tags in general. is_page() takes both post IDs as well as slugs (and more) as arguments, hence you can choose how you’d like to identify the page in question. With the above given ID, this, for instance, ought to work: if( function_exists(‘cp_alterPoints’) && is_page(24122) … Read more

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