• Resolved milauskas

    (@milauskas)


    Hi,

    I want to add an image above the page title on the home page. I’ve added a custom field and in the value section I added the location of an image.

    When I view the page, the image displays fine, but the name of the custom field is right there to the left of it (e.g., img_post_header).

    I want only the image to show up without the name of the custom field. Can I do this? I read that adding an underscore to the name causes wordpress to ignore or hide the name, but when I try to do this in the name field, then attempt to update the custom field, an error appears:

    An unidentified error has occurred.

    Can anyone help me find a solution? Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • When I view the page, the image displays fine, but the name of the custom field is right there to the left of it (e.g., img_post_header).

    what is the code that you used to show the image?

    also, please post a link to your site to illustrate the problem.

    Thread Starter milauskas

    (@milauskas)

    Here’s the code:

    <img src="https://jetsettest.com/paul/wp-content/uploads/2011/09/sample1.gif" />

    You can see it here: https://jetsettest.com/paul/

    I believe @alchymyth was looking for the full code you use to call the custom field / meta data

    Thread Starter milauskas

    (@milauskas)

    Sorry Voodoo, here’s the code for my page template (snarfer.php).

    [code moderated - please follow the forum guidelines for posting code]

    The only thing I added was this: <?php the_meta(); ?>

    I was just following a tutorial I found online so I don't know all the ins and outs of doing some things in WP.

    well normally

    <?php echo get_post_meta($post->ID, 'img_post_header', true); ?>

    is what you want… inside the loop

    You are working outside the loop…. but it may work in this situation, you can give it a try instead of you the_meta call

    it may work better in your loop here

    while (have_posts()) {
    			the_post();
                               echo get_post_meta($post->ID, 'img_post_header', true);

    Thread Starter milauskas

    (@milauskas)

    It worked! Thank you so much. I’m still not very good with PHP.

    You really saved me a lot of grief!

    I’m not good with php either, just over time, I’ve learned WP functions.

    To be good at wordpress, you just need to understand php relevant to wordpress. Look at some themes, find some template tags or something, and search the codex, or google to see what you can do with it

    I started copying and pasting, and figured out enough to piece things together, and then slowly to write my own custom code, etc….

    It just comes with a bit of practice

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Hide custom field name?’ is closed to new replies.