900 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+4 more
Gareth_Gillman says

I have this command

<?php snippets_value( 'fieldname' ); ?>

How do I add a PHP command within the command? I want to add a WP tag within the above, the tag I want to use is the_slug() so it would read:

<?php snippets_value( the_slug() ); ?>
Any help is appreciated as PHP isn’t my strong point
1724 posts LoveThemes
  • Nominated Community Superstar of the month
  • Contributed a blog post
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
+8 more
LoveThemes says

You’re going to need to elaborate on what you’re trying to acheive. Are you trying to concatenate the 2? grab a value? Append?

-Scott

3503 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Located in United States
  • Helps us moderate the forums
+10 more
sevenspark Moderator says

The only way that will work is if the inner function returns a valid value to pass to the outer function. Most WordPress template tags with the naming convention the_{tag}() print (echo) a value, rather than return it (get_the_{tag}() is often the equivalent function that returns the value).

If a function prints a value and returns nothing, you can’t use it to pass a value inside another function call.

236 posts
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
GradaStudio says

first of all these are functions..

and <?php snippets_value( the_slug() ); ?> will work fine as long as the_slug() returns a value and not echo or print it. :)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by