jtsternberg / GC-Sermons

Church sermon management for WordPress
9 stars 1 forks source link

Retrieving Attributes of Speaker #15

Open davidshq opened 8 years ago

davidshq commented 8 years ago

I'm wondering if this is similar to Issue 14 I posted earlier. In the previous case I wanted to pull an image attachment into a post from the series and add a CSS class. You gave me something like this:

`$series = gc_sermons()->taxonomies->series->get( get_queried_object_id() );
        if ( $series->image_id ) {
            echo wp_get_attachment_image( $series->image_id, 'full', false, array(
                'class' => 'gc-single-series-sermons-img',
            ) );
        }`

Now I want to pull in the name of a speaker, I've tried this:

`$speakers = gc_sermons()->taxonomies->speakers->get( get_queried_object_id() );
     echo $speakers->name;`

But that didn't work. I also tried:

 `$speakers = $sermon->get_speaker();
     foreach ($speakers as $speaker) {
        $name = $speaker->name;
        echo $name;
    }`

But this didn't work either. What did work (somewhat) is dumping everything from $speakers - but I don't want everything - just the individuals name. Here is how I dumped everything from $speakers

   `$speakers = $sermon->get_speaker();
    foreach ($speakers as $speaker) {
        echo $speaker;
    }

I seem to be missing some key concept. Any suggestions?

davidshq commented 8 years ago

FYI, the way I ended up fixing this was: $speaker = $sermon->get_speaker(); echo $speaker->name; So, this pulls in a name but I'm not sure how to pull in multiple names.