454 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Microlancer Beta Tester
  • Referred between 1 and 9 users
  • United Kingdom
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
1152 posts
  • Interviewed on the Envato Notes blog
  • Won a Competition
  • Halloween Competition Winner
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 50 000 and 100 000 dollars
  • Referred between 100 and 199 users
  • Bought between 1 and 9 items
  • United Kingdom
iKreativ 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

3363 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred more than 2000 users
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+4 more
sevenspark Volunteer 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
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Has been a member for 3-4 years
  • Bought between 1 and 9 items
  • Microlancer Beta Tester
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. :)

by
by
by
by
by
by