SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Forcing Function to Return instead of Echo?

    I'm trying to add a link to the bottom of my wordpress RSS Feed but my getCustomField('Affiliate Link') function is echoing the value instead of returning it.. how do I get it to return instead?


    PHP Code:
        function modRSS($content) {
           global 
    $post;
         
           if ( 
    has_post_thumbnail$post->ID ) ){
              
    $content '<div>' get_the_post_thumbnail$post->ID'full', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' $content;
           }
         
           
    $content $content '<a href="' getCustomField('Affiliate Link') . '">Peek</a>';
         
           return 
    $content;
        }
         
        
    add_filter('the_excerpt_rss''modRSS');
        
    add_filter('the_content_feed''modRSS'); 

  2. #2
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See if it is possible to add default parameter in your function getCustomField('Affiliate Link') like

    PHP Code:
    function getCustomField($mylink$return false){
        
    // do your stuff here
        
    if($return)
            return 
    $yourValue;
        else 
            echo 
    $yourValue;

    and then call your function like getCustomField('Affiliate Link', true)

    Hope this helps
    Barbara

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by barbara1712 View Post
    See if it is possible to add default parameter in your function getCustomField('Affiliate Link') like

    PHP Code:
    function getCustomField($mylink$return false){
        
    // do your stuff here
        
    if($return)
            return 
    $yourValue;
        else 
            echo 
    $yourValue;

    and then call your function like getCustomField('Affiliate Link', true)

    Hope this helps
    Thanks for the reply! I don't know php too well, just trying to fix this one thing but what would I place where it says "yourValue"?

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,121
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Can you provide the getCustomField function you have so we can see it? Otherwise we are just guessing as to what the function looks like.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •