0

I need to send some variable from template file (themes/template/page-profile.php) to the plugin file(plugin/instagram-slider/instagram.php).

For example: I have

$instagram_url = get_user_meta($user_data->ID, 'instagram_url', true);

I need to send that $instagram_url to plugin file:

private function display_images( $args ) 
{
$username = $instagram_url;
}

Any suggestions on how I might do this?

1 Answer 1

0

You can use this way:

private function display_images( $args ) 
{
    $instagram_url = get_user_meta($user_data->ID, 'instagram_url', true);
    $username = $instagram_url;

 //You can use $username in another function by simply call it using global method.
 }

This is an easy way to get the post meta data in your custom plugin file.

3
  • Thanks @mukii kumar, This may help me somewhere. But i need to know is there any way to pass the variables like this defined in page-templates to plugin file
    – Naresh
    Apr 12, 2017 at 5:51
  • #naresh make the $instagram_url global i.e: like "global $instagram_url" in your theme file. Might be this will help you Apr 12, 2017 at 6:02
  • Thankyou so much @mukii kumar. This helped me and saved my day
    – Naresh
    Apr 12, 2017 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.