Custom Fields: Not appearing on the site page!

Asked

Viewed 488 times

0

I have a page with custom fields, so far so good, but when saved on the site does not appear the field, that would be a BLOCK.

A página com os campos personalizados

I used the code <?php the_meta(); ?> and appeared like this, messy:

conteudo bagunçado

I don’t know what to do! This site was developed by another professional, I’m trying to make a change, which in my view was simple...:(

In the home of the site this same content appears in blocks, one on the other side.

I’ve already looked at the PHP file, I’ve looked at everything, and I can’t load the contents with the correct formatting.

1 answer

1


Buddy use this Function, put it in any luga in functions.php

function pegar_campo( $field_name, $post_id = false ) {

$value = get_post_meta($post_id, $field_name);

if( is_array($value) )
{
    $value = @implode(', ',$value);
}

return $value; }

makes it easier to recover in the post, put:

<?php echo pegar_campo('campo', $post->ID); ?>

I use this Function in my themes, give a tested

  • Do I put so? <? php echo get_the_meta('block', $post->3764); ?>

  • Buddy, I changed the answer, take a look, it’ll be simpler for your person!

  • The group I created in the plugin is http://ramosdesign.com.br/grupo.jpg. and on the editing page it looks like this: http://ramosdesign.com.br/007.jpg are actually two blocks, one partner that should look like this: http://ramosdesign.com.br/partners.jpg and another that we do would look like this: http://ramosdesign.com.br/bloco2.jpg

  • In your error it showed the custom fields you have, here they follow: Subtitle, banner, what we do_0_image, what we do_0_title, what we do_0_summary, what we do_0_content If you want the title for ex you use: <? php echo peg_campo('Subtitle', $post-ID); ? > use the Function I sent you there, it will be a very strong help for you!

  • Poxa Rafael, thanks by force! Already began to appear the content. Would not have this function to call the whole group?

  • if you want to call the whole group use each code to pull each thing, it would look like this: <? php echo peg_field('Subtitle', $post->ID); ? > <? php echo peg_field('banner', $post->ID); ? > <? php echo peg_field('what to do_0_image', $post->ID); ? > <? php echo peg_field('what do we do_0_title', $post->ID); ? > <? php echo peg_field('what do we do_0_summary', $post->ID); ? > <? php echo pegar_campo('oquefazemos_0_conteudo', $post->ID); ?>

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.