WordPress.org

Ready to get started?Download WordPress

Forums

Display only the value from the Custom Field (6 posts)

  1. meher
    Member
    Posted 1 year ago #

    Hi friends,

    I am working on a project in WordPress 3.1.4.

    On different pages in WordPress, I have added 1 Custom Field.

    For pages, I want to display only the value from the custom fields.

    I am using <?php the_meta(); ?> function in my theme file, but the name and value both are displayed.

    Please may I know how to display only the value from the custom field?

    Any help will be appreciated.

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

  3. meher
    Member
    Posted 1 year ago #

    Hi Alchmyth,

    I did review of get_post_meta().

    When using get_post_meta(), no output was displayed. Hence I used the_meta().

    Any help will be appreciated.

  4. gidd
    Member
    Posted 1 year ago #

    I think get_post_meta(); does what you want. You might not call it properly. Here is an example:
    echo get_post_meta( get_the_ID(), 'your_key', true );

  5. meher
    Member
    Posted 10 months ago #

    Hi gidd,

    Thank for the reply.

    Sorry did not reply earlier.

    I am adding the get_post_meta(), in loop-page.php. Is that rite?

    I am still not receiving any output?

    Any help will be appreciated...

  6. gidd
    Member
    Posted 10 months ago #

    I don't know how your theme is structured. Usually, it is page.php. You might put the code in a location where get_the_ID() cannot read the page ID.

    You can test this by replacing get_the_ID() with the real page ID from WordPress admin.

Topic Closed

This topic has been closed to new replies.

About this Topic