how can i get shortcode call text and shortcode within the text

Discussion in 'PHP' started by macaela, May 29, 2012.

  1. #1
    Hi I have the 2 shortcodes function one that pick up the latest news but within that news article I would like in the middle of the text a shortcode to display an image in the middle.

    the problem is that when I run the latestnews shortcode it doesnt run the other shortcode within a shortcode.

    [image_shortcode] == <img src"image" >

    example- article:
    The forums.digital is a greate forum its helpfull and great to meet new people [image_shortcode] almost everyday I came here to chat to people.

    call the article:
    [latestnews]
    Incorrect Result:
    The forums.digital is a great forum its helpfull and great to meet new people [image_shortcode] almost everyday I came here to chat to people.

    The result I want
    Article:
    The forums.digital is a great forum its helpfull and great to meet new people <img src"image.gif" > almost everyday I came here to chat to people.

    This is my shortcode functions

    Latest news
    
    //[latestnews]
    <?php 
    //function to display the latest news published one post only
    function wptuts_latestnews_shortcode($atts, $content=null) {
       query_posts(array('orderby' => 'date', 'order' => 'DESC' , 'showposts' => 1 , 'category_name' => 'Blog / News'));
       if (have_posts()) :
          while (have_posts()) : the_post();
    	  global $more;    // Declare global $more (before the loop).
    		$more = 0;       // Set (inside the loop) to display content above the more tag.
    		
             $return = get_the_content  ("» read more") ;
          endwhile;
       endif;
       wp_reset_query();
       return $return_string;
    }  
    add_shortcode( 'latestnews', 'wptuts_latestnews_shortcode');
    ?>
    PHP:
    Image shortcode
    
    //[image]
    <?php 
    function wptuts_image_shortcode($atts, $content=null){  
      
        $tweet = '<a img="img2.gif" href="/news/" title=" latest news">latest news</a>';  
      
        return $image;  
      }  
      
      add_shortcode('image', 'wptuts_twitter_shortcode');
      
    ?>
    PHP:
    I have tried the do_shortcode
    $return = get_the_content  ("» read more") . do_shortcode($content) ;
    PHP:
    But the image just display at the end of the article I want in the middle of the article
     
    macaela, May 29, 2012 IP