I would like to have custom fields in my posts and the value that I enter in for that post gets displayed at the end of the post url when you click on it. I would like to add ?fromwhere=news” at the end of some posts or ?fromwhere=videos”, ?fromwhere=phots etc. I can sucesfully add in ?fromwhere=news manually, but I would like to do it with custom fields so it would be much easier for me. Here is the code I have so far:
$returnlink = ($this->params['lightbox'])? ('"'.$cg_url.'/includes/CatGridPost.php?ID='.$single->ID.'" class="cgpost"') : (''.get_permalink($single->ID)).''; $news = get_post_meta($post->ID, 'newsMP', true); $cgfontsize=$this->cg_get_font_size(); $excerpt = apply_filters('get_the_excerpt', $single->post_excerpt); $post = get_post($single->ID); // unless $single is already a complete object $cgtitle='<div class="cgback cgnojs '.$this->params['showtitle'].'"></div><div class="cgtitle cgnojs '.$this->params['showtitle'].'"><p style="font-size:'.$cgfontsize.'px;line-height:'.(1.2*$cgfontsize).'px;"><a href="'.$returnlink.''.$news.'">'.$title.'</a></p><div id="lol">'.$excerpt.' </div></div>'; return $cgtitle; }
So this grabs the title, excerpt and post id and displays it back to wordpress. As you can see I tried using get_post_meta to get the custom field in wordpress and then I put ‘.$news.’ right and the end of the return link. What I get is, nothing. Absolutely nothing. 🙁 I’m typing in text in the custom field titled “newsMP” but it doesn’t display annythhhiiiiiing. I’m going to add more coding to this like if statments that say if customfield is this, then do this. 🙂
If anyone could help me out it would make me really really happy lol.
- The topic ‘Custom Fields That Add Text After Post Url’ is closed to new replies.