Posting from a short tag
-
I’m using “Kalin’s Recent Posts plugin to produce a list of recent posts including title, post date, thumbnail and excerpt. The plugin allows me to insert which short tags I want in any order I choose. The problem is some of my posts will have images, some won’t. The [post_thumb] short tag generates the full url of the image and therefore requires use of <img src=[post_thumb]/> in the plugin interface. The problem is if no image exists it displays the stupid little missing image gif. I’ve tinkered with the code to include an if statement to only create the shot tag if there is an image but I’ve no idea how to get it to display. Obviously I’m VERY new to this and any HELP! would be appreciated. Here’s the code for that portion of the pliugin:
$postCallback->post_type = $page->post_type; $postCallback->post_id = $page->ID; $str = preg_replace_callback('#\[ *post_pdf *\]#', array(&$postCallback, 'postPDFCallback'), $str); if(isset($str)){ $arr = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'single-post-thumbnail' ); $str = str_replace("[post_thumb]", $arr[0], $str); }else{ }
[Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum’s parser.]
- The topic ‘Posting from a short tag’ is closed to new replies.