How do I integrate custom post with sidebar?
Support › MB Custom Post Type › How do I integrate custom post with sidebar?Resolved
- This topic has 5 replies, 2 voices, and was last updated 6 years, 9 months ago by
Anh Tran.
-
AuthorPosts
-
July 9, 2018 at 10:17 PM #10499
dd32137
ParticipantHi,
I've created a custom post type. I've also created a MetaBox. I've added the PHP code to my single.php file and set the "field_id". My problem is that I can't figure out how to get the MetaBox to tie to the Post Type and then put them into the sidebar. I figure the sidebar should be easy enough because I can use custom html so I should be able to insert shortcode into the sidebar component to solve that. At the moment, I'm not getting any error messages, but it is not displaying the post either.
What am I missing?
I appreciate your help!
July 11, 2018 at 4:01 PM #10513Anh Tran
KeymasterHello,
Can you give me more details on "get the MetaBox to tie to the Post Type and then put them into the sidebar"? Do you mean registering a meta box (with custom fields) for the custom post type and outputting the custom fields' values in the sidebar?
July 11, 2018 at 7:56 PM #10521dd32137
ParticipantYes, that sounds correct.
July 12, 2018 at 10:18 AM #10534Anh Tran
KeymasterHi, to register a meta box for a custom post type, please:
- Go to Meta Box > Custom Fields, click Add New to add a new field group.
- Then add fields you want from the left panel.
- Click the tab Settings and select "Posts" in "Show for", and then select your post type below.
- Click Save Changes button
Now go back to your custom post type edit screen and you'll see the meta box appear. Enter some info and update the post.
To show the custom fields's values in the sidebar, there are 2 ways:
July 18, 2018 at 11:12 PM #10624dd32137
ParticipantOk, I've done everything you said...with a couple of differences where my screen didn't match your description. I see the metabox in my custom post type, so that's great. The problem I'm having now is that no matter what I do, it still won't show in the side bar.
I've added a text widget to my sidebar and pasted the [rwmb_meta meta_key="mbQuotes"] in the Text tab. Nothing shows up.
I've added a text widget to my sidebar and pasted the code into the Visible tab. It shows the code and not the value of the post.
I've added a Shortcode Widget to my sidebar and pasted the code in there. Nothing Shows.
I've tried changing the mbQuotes (name of Metabox) to the actual field name within the metabox (txtQuotes) but got nothing.
I'm at a loss now.
July 20, 2018 at 3:53 PM #10637Anh Tran
KeymasterHi, do your fields have any prefix? In the shortcode, the
meta_key
should be the full field ID, including the prefix (if any).If you still have any trouble showing the data, please send me an email via the contact form.
-
AuthorPosts
- You must be logged in to reply to this topic.