troubleshooting Question

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

Avatar of niceoneishere
niceoneishere asked on
Web DevelopmentPHPWordPress
7 Comments1 Solution76 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 );
}


}

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');

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

Thanks
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
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 1 Answer 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