Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9115737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:30:09+00:00 2026-06-17T04:30:09+00:00

I need to modify this code to show get custom fields just for the

  • 0

I need to modify this code to show get custom fields just for the post on which the user currently is.

// this needs to be modified
<?php
global $post;
$args = array('category' => 37, 'post_type' => 'post' ); 
$postslist = get_posts( $args ); 
foreach ($postslist as $post) : setup_postdata($post); 
?> 
// end this needs to be modified

<?php if( get_post_meta($post->ID, "Title", true) ): ?>
<?php echo get_post_meta($post->ID, "Title", true); ?></p>
<?php endif; ?>

Because this will be included, I cannot make it just with get_post_meta.

Many thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:30:11+00:00Added an answer on June 17, 2026 at 4:30 am

    This ignores the loop and only shows the custom field for the current page, notice get_the_ID():

    <?php if( get_post_meta(get_the_ID(), "Title", true) ): ?>
        <p><?php echo get_post_meta(get_the_ID(), "Title", true); ?></p>
    <?php endif; ?>
    
    <?php
    global $post;
    $args = array('category' => 37, 'post_type' => 'post' ); 
    $postslist = get_posts( $args ); 
    foreach ($postslist as $post){
        setup_postdata($post);
    }
    ?> 
    

    And this will output all custom fields named “Title” from within the loop:

    <?php
    global $post;
    $args = array('category' => 37, 'post_type' => 'post' ); 
    $postslist = get_posts( $args ); 
    foreach ($postslist as $post){
        setup_postdata($post);
    
        echo('<p>'.get_post_meta($post->ID, "Title", true).'</p>');
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to modify an existing script which uses SED to search and replace
Sometimes I need to modify a third party library for my specific needs. It
The base zip code used in this query is the lat/lng for 90210 which
I'm using this code to get all IDs from a category. Mage::getResourceModel('catalog/product_collection')->setStoreId($storeid)->addCategoryFilter(Mage::getModel('catalog/category')->load($subcatid))->getAllIds(); However, this
I wonder how could I modify this existing code in order to track image/banner
Hey, can you help me figure this out? I need to hide/show a div
I am trying to modify someone else's extjs code and I really need some
I find myself writing this class often in my python code when I need
how to modify this imageCheckBoxAdapter code in order to maintain status of checkBox when
A lot of code have been deleted, but I really need to show only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.