Forums

PHP THE META (5 posts)

  1. teckn1caLity
    Member
    Posted 10 months ago #

    I've been using '<?php the_meta(); ?>'
    for about 2 days and it just started glitching out on me.

    This is what's appearing now instead of my actual meta data.

    dsq_thread_id: 361800013
    producer: Cardiak

    "Producer: Cardiak" is the only thing that should be showing

    Any ideas?

    On another post it was pulling

    enclosure: http://www.selecterz.com/wp-content/uploads/2011/07/Curreny-Run-Dat-Shit-Prod.-by-Monsta-Beatz.mp3 5351164 audio/mpeg
        producer: Monsta Beatz
        dsq_thread_id: 360285713

    Which it should only be pulling "Producer: Monsta Beatz"

    That particular post had an audio file embedded using Audio Player.

  2. simplistik
    Member
    Posted 10 months ago #

    That's because you are telling it to call all the meta associated w/ the post. You need to use

    get_post_meta()

    http://codex.wordpress.org/Function_Reference/get_post_meta

    Then you would do:

    $producer = get_post_meta($post->ID, 'producer', true);

    then replace the the_meta() with

    _e($producer)

  3. teckn1caLity
    Member
    Posted 10 months ago #

    I understand what you're trying to explain for me to do, I'm simply just really confused. From what you said this is what I came up with.

    <?php $meta_values = get_post_meta($producer = get_post_meta($post->ID, 'producer', true); ?>

    ???

    Am I creating a function and using the get_post_meta call? I'm really confused man.

  4. simplistik
    Member
    Posted 10 months ago #

    No, your exact code would look like what I posted. Because you only want to obtain one value 'producer' you only need to call that specific post_meta value so you literally only need

    $producer = get_post_meta($post->ID, 'producer', true);

    so where you have

    <?php the_meta(); ?>

    replace it with:

    <?php
        $producer = get_post_meta($post->ID, 'producer', true);
        _e($producer);
    ?>
  5. teckn1caLity
    Member
    Posted 10 months ago #

    Alright, it works perfectly. Really appreciate the assistance man.

Reply

You must log in to post.

About this Topic

Tags

No tags yet.