Archived

This topic is now archived and is closed to further replies.

  • 0

Custom fields in Post Metabar


Question

Posted · Report post

Hello, I want to show the content of a custom field in the post metabar. Is it possible?

Is there a shortcut?

 

Share this post


Link to post
Share on other sites

8 answers to this question

Posted · Report post

The post metabar only accepts the shortcodes provided by PageLines, but it should be possible to display the content of a custom field somewhere else in the post area. Please see for further info: http://codex.wordpress.org/Custom_Fields

Share this post


Link to post
Share on other sites

Posted · Report post

Hi Johnny 

 

Could you please create a new thread if you need help with this one, as this thread has been marked answered already, any further responses might not be seen by the moderator team.

 

As you're a member of the Pl Developer group you might also be able to check in the skype clan chat to see if anyone knows the answer on the underscores being stripped out. Otherwise drop a new thread and we'll try and check with the core dev's for you.

1 person likes this

Share this post


Link to post
Share on other sites

Posted · Report post

johnny_n Soory but your doing_it_wrong() ;) Shortcodes should never EVER output anything, the function has to return it back. for example:

function custom_break_func($atts) {

    return "<br />";

}

add_shortcode('custom_break', 'custom_break_func');

1 person likes this

Share this post


Link to post
Share on other sites

Posted · Report post

Fantastic.  Thank you James and Simon - this works beautifully.  Others might find a use for this as well.

 

Appreciate the lesson too, Simon - I had read the Codex shortcodes page a couple of times but your statement is to the point!  :-)

Share this post


Link to post
Share on other sites

Posted · Report post

OK, thank you Catrina.

Share this post


Link to post
Share on other sites

Posted · Report post

Thanks Advocate, but is too much for me. I´m creating a calendat of events an only want to show in the blog a list of Image, Title and date (this is in the future). If it´s imposible in the meta, i´ll try how looks in the excerpt. 

Share this post


Link to post
Share on other sites

Posted · Report post

This doesn't seem to work.  I'm trying to output a break to split the metabar up into two lines for legibility.

 

 [post_date] [custom_break]Categories:

 

 

The function is simple, (I've tried both with '<br /> and 'n' but that's not the issue:

 

 

function custom_break_func($atts) {
	echo "<br />";
}

add_shortcode('custom_break', 'custom_break_func');

 

 

What happens is it's not output in the metabar but above it, right after the copy-pad div:

 


<div class="copy-pad"><br /><article class="post-623 post type-post status-publish format-standard hentry category-events...


 

 

I discovered this by outputting a word, instead of the break.  For some reason the underscores are being removed from the function above but they are there.

Share this post


Link to post
Share on other sites