Title: PHP in variable?
Last modified: August 20, 2016

---

# PHP in variable?

 *  [arthurdent2003](https://wordpress.org/support/users/arthurdent2003/)
 * (@arthurdent2003)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/php-in-variable/)
 * Hi there – i have a question about php.
 * I use “smooth slider” old version and I’d like to have something that calls a
   custom field.
 * I’ve found the code where I’d love to let the custom field show up. But after
   hours, I don’t get it to work. I think it’s just an easy noob mistake:
 * Here is the code:
 *     ```
       $html .=  sslider_get_the_image($img_args);
   
       		if(!$smooth_slider['content_limit'] or $smooth_slider['content_limit'] == '' or $smooth_slider['content_limit'] == ' ')
       		  $slider_excerpt = substr($slider_content,0,$smooth_slider['content_chars']);
       		else
       		  $slider_excerpt = smooth_slider_word_limiter( $slider_content, $limit = $smooth_slider['content_limit'] );
   
       		if ($smooth_slider['image_only'] == '1') {
       			$html .= '<!-- /smooth_slideri -->
       			</div>';
       		}
       		else {
       		   if($permalink!='') {
       			$html .= '<h2 ><a href="'.$permalink.'">'.$post_title.'</a></h2><span> '.$slider_excerpt.'</span>
       				<p class="more"><a href="'.$permalink.'">'.$smooth_slider['more'].'</a></p>
   
       				<!-- /smooth_slideri -->
       			</div>'[....]
       ```
   
 * I tried to make something like `$mymeta = get_post_meta($post->ID, "mycustomfield",
   true);` and I wanted to have it in the Title:
 * `.$post_title.'</a></h2><span>’
 * So I wrote it like this:
    `.$post_title.'</a></h2>'.$mymeta.'<span>'` but it 
   doesn’t work. I can’t see anything on the frontend.
 * So my question: how can I put “php” into this code to show my custom field value
   right next to the Title??
 * Thank you!!!
 * AD

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/php-in-variable/#post-2161286)
 * It would go something like this..
 *     ```
       //
       		$mymeta = get_post_meta( $post->ID, "mycustomfield", true );
       		$html .= '<h2><a href="'.$permalink.'">'.$post_title.'</a>'.$mymeta.'</h2><span> '.$slider_excerpt.'</span>
       		<p class="more"><a href="'.$permalink.'">'.$smooth_slider['more'].'</a></p>
       		<!-- /smooth_slideri -->
       		</div>'
       ```
   
 * However, i’m not sure you have `$post` (you’ll need it to use `$post->ID`) available
   to you(hard to tell without seeing more of the surrounding code), which may be
   the issue, if you do then the above should help.
 *  Thread Starter [arthurdent2003](https://wordpress.org/support/users/arthurdent2003/)
 * (@arthurdent2003)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/php-in-variable/#post-2161288)
 * thats the original Part in the code:
 * _[code moderated per [forum rules ](http://codex.wordpress.org/Forum_Welcome#Posting_Code)-
   please use the [pastebin ](http://pastebin.com/)for any code longer than 10 lines;
   
   i also deleted your previous post because of the code overload; if that code 
   was important, please use the pastebin]
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/php-in-variable/#post-2161290)
 * Wow, that’s alot of code, unfortunately there seems to be a bug that prevents
   me from trimming it from your reply(odd)..
 * As far as i can see you should be able to reference `$post_id` instead of `$post-
   >ID`, and that should solve the problem.. 🙂
 * If you can edit the above(not the reply directly above, the huge one before that),
   please do so and remove the code, then place it into a [pastebin](http://pastebin.com/)
   please.
 *  Thread Starter [arthurdent2003](https://wordpress.org/support/users/arthurdent2003/)
 * (@arthurdent2003)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/php-in-variable/#post-2161292)
 * > As far as i can see you should be able to reference $post_id instead of $post-
   > >ID, and that should solve the problem.. 🙂
 * yes! that’s it! Thank you very much! I was really getting nuts 🙂
 * I tried to edit the post above, after I saw that’s a bit too long, but I can’t–
   the post is not showing up…sorry for that! I’ll try it again!
 * Thank you for your help!!!
 * AD
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/php-in-variable/#post-2161293)
 * Happy to help, and looks like another mod removed the code overflow for us.. 
   🙂
 * Glad to hear you’ve got things working how you want them.. 🙂
 *  Thread Starter [arthurdent2003](https://wordpress.org/support/users/arthurdent2003/)
 * (@arthurdent2003)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/php-in-variable/#post-2161294)
 * Yes – thank you guys! 🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘PHP in variable?’ is closed to new replies.

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [question](https://wordpress.org/support/topic-tag/question/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 6 replies
 * 2 participants
 * Last reply from: [arthurdent2003](https://wordpress.org/support/users/arthurdent2003/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/php-in-variable/#post-2161294)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
