how to test for attached image

function has_image_attachment($post_id) { $args = array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image/jpeg’, ‘numberposts’ => -1, ‘post_status’ => null, ‘post_parent’ => $post_id ); $attachments = get_posts($args); if(is_array($attachments) && count($attachments) > 0) { //Has image attachments return true; } else { return false; } }

Can shortcodes contain conditional statements? Even without them my shortcode renders blank page

your conditional breaks the concatenation of the strings (which is not in your code, anyway) try to re-write this section: function info($atts, $content = null) { extract(shortcode_atts(array( “name” => ”, “image” => ”, “address” => ”, “phone” => ”, “email” => ”, “website” => ”, “description” => ”, “amenities” => ” ), $atts)); $output=”<span class=”sort”>”; … Read more

If post author role is X

One way to do it is getting the author data and checking it’s role with get_userdata() Codex For that you will need the user ID, and you can get that with get_post_field() Codex You will need the post ID to use the get_post_field(), so you can use the get_queried_object_id()Codex So, you would have something like: … Read more

Show content after the first and second paragraph

My way to do this (see update below): function addParagraphs($content) { // you can add as many as you want: $additions = array( ‘<p>After 1st paragraph</p>’, ‘<p>After 2nd paragraph</p>’ ); $content = get_the_content(); $output=””; // define variable to avoid PHP warnings $parts = explode(“</p>”, $content); $count = count($parts); // call count() only once, it’s faster … Read more

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