Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

DenisCGN on "Custom META in wpSEO plugin"

$
0
0

Hello,
I use the wpSEO plugin. And it offers the possibility to change the meta via a function.

This is the function:

add_action('init', 'set_wpseo_meta');

function set_wpseo_meta() {
    apply_filters(
        'wpseo_set_meta',
        array(
            'title' => 'Neuer Titel',
            'desc' => 'Neue Description',
        )
    );
}

When I use it with static data it works well. No I like to have custom fields and taxonomies be used for creating the meta.

This is how I get my dynamic meta.

global $wp_query;

$artists_list = wp_get_object_terms( $wp_query->post->ID, 'mhq_artists' );
$label_list = wp_get_object_terms( $wp_query->post->ID, 'mhq_labels' );
$cdTitle = get_post_meta( $wp_query->post->ID, 'my_meta_box_Title', true );
$cdRelease = get_post_meta( $wp_query->post->ID, 'my_meta_box_dateRelease', true );

foreach( $artists_list as $artists )
$artist_names[] = $artists->name;

foreach( $label_list as $labels )
$label_names[] = $labels->name;

$artist_names = implode( ', ', $artist_names );
$label_names = implode( ', ', $label_names );

Now, how do I get this dynamic into the function?

When I try to change the variable with the static text I got an error.

And, I like to have this all, only if(is_single()).

Can someone tell me how this works?

Cheers,
Denis


Viewing all articles
Browse latest Browse all 8245

Trending Articles