• I am using WordPress 3.5.1 / Twenty Twelve Theme.
    I would like to display a custom field in my Category Archives.
    I have the following custom field working in my single.php , it displays a custom url / title

    <a href="https://<?php echo get_post_meta($post->ID, "user_submit_url", true); ?>" target="_blank">  <h1 class="entry-title"><?php the_title(); ?> </a> <br /> <!-- Inserts the submitted url to the title -->

    I would like to put the following code underneath the “entry-title” in Category Archives. I am confused of were to put the following php code, either in category.php or archive.php?
    Since I need to put this code inside the loop, I want the code to register on every post just like it registers in the single.php in the example I provided above.
    Something like the following, I presume?

    get_post_meta($post->ID, "user_submit_url", true);

    Let me know if I need to clarify anything.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Unless you have a more specific category template, category.php would be the one used. It’s often not easy to discern which template is used under what condition. I ended up putting the filename inside of html comments in each template file so I could identify templates used by viewing the html source in my browser.

    Your template code proposal is appropriate except you need to put echo in front of it so the returned value is output to the browser. And of course it needs to be inside of a <?php ?> block.

Viewing 1 replies (of 1 total)
  • The topic ‘Displaying a custom field in Category Archives’ is closed to new replies.