• Resolved morollian

    (@morollian)


    Hello,

    I’m trying to use the_meta() in my single custom post ( single-{slug}.php ) and worpdress just won’t echo it. This is the code I’m using:

    <h2><?php $key="Expo-Subtitle";
    $value_expo =get_post_meta($post->ID, $key, true);
    echo $value_expo;?></h2>

    While it’s working great in the category page (Where it is running within the Loop), it just won’t work in single.php.

    I’m guessing it may be because single post pages are outside the loop.

    Does anyone now how could I fetch the post meta from the single post page? the_title() and the_content() work great, but it seems to work in a diferent way when it’s the_meta().

    Any key or guidance here would be really helpfull!

    Thanks

Viewing 1 replies (of 1 total)
  • Thread Starter morollian

    (@morollian)

    I solved it using <?php the_meta(); ?> instead, and styling the
    <ul> and
    <li> elements that this function returns and echoes.

    The CSS class that WP gives to this elements are:
    .post-meta (for the
    <ul> element)
    .post-meta-key (for the
    <li> elements).

    That worked great for me,

    You can find more info here in the codex

Viewing 1 replies (of 1 total)
  • The topic ‘Using the_meta() in a single-{slug}’ is closed to new replies.