troubleshooting Question

Wordpress echo a variable from a function that is inside a class

Avatar of niceoneishere
niceoneishere asked on
PHPWordPressWeb Development
7 Comments2 Solutions77 ViewsLast Modified:
Hi There,

I have created a class which hold multiple functions. One of the function gets all the details about the author of a custom post type. I am trying to display the variables from this function in my author template.

Below is the code for my class that is in the functions.php

class pc_npPosts
{

function pc_get_np_info(){

       $pc_np_author_id    = get_query_var( 'author' );
        $pc_np_name = get_field('np_organization_name', 'user_'.  $pc_np_author_id);
        $pc_np_bio  = apply_filters('avf_author_description', get_the_author_meta('description',  $pc_np_author_id),  $pc_np_author_id);
        $pc_np_whatWeDo = get_field('np_what_we_do', 'user_'.  $pc_np_author_id);
        $np_organization_logo = get_field( 'np_organization_logo', 'user_'. $pc_np_author_id  ); 
        $np_profile_link = get_author_posts_url($pc_np_author_id);
        $np_organization_address = get_field( 'np_organization_address', 'user_'. $pc_np_author_id  ); 
        $np_organization_city = get_field( 'np_organization_city', 'user_'. $pc_np_author_id  ); 
        $np_organization_state = get_field( 'np_organization_state', 'user_'. $pc_np_author_id  );
        $np_organization_zipcode = get_field( 'np_organization_zipcode', 'user_'. $pc_np_author_id  );  
        $np_causes_interests = get_field( 'np_causes_interests', 'user_'. $pc_np_author_id );
}


}

Open in new window


I would like to display the above variable in author template like below

 $pc_np_author = New pc_npPosts;

 echo $pc_np_class->pc_get_np_info('pc_np_name');

Open in new window


but nothing displays. What am I missing or doing wrong.

Thanks
ASKER CERTIFIED SOLUTION
gr8gonzo
Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros