Home › Forums › Themes Support › Circle › How to add new Metabox to Circle Single Video, Film, Actor or Director
Tagged: metabox
- This topic has 10 replies, 3 voices, and was last updated 4 years, 6 months ago by
admin.
-
AuthorPosts
-
November 1, 2017 at 4:19 am #782
Hi all customer,
In this tutorial we will help you customize to add more information you need to display in our custom post type as single Video, Film,…
Requirements: You need know about PHP and RW Metabox and base about WP_Query. Of course you need know about CSS too. We will do example with Video Post type
Note: Because you can keep your custom work use child theme, In this case before update our theme to latest version you need backup and store all file not in templates folder like theme-metabox.php, …
Step 1: Add more metabox to Video Post type
- Go to {yourwebroot}/wp-content/themes/haru-circle/framework/includes/ then open file theme-metabox.php
-
- Go to line 220 you will see Video Metabox or search this word: Video metabox
- Example we will add an metabox field name is label (Video New, Hot, Trending,…)
- You can see example demo for Metabox here: https://docs.metabox.io/fields/autocomplete/
- The code added will like this
array(
‘id’ => ‘haru_video’ . ‘_label’,
‘name’ => esc_html__( ‘Title’, ‘haru-circle’ ),
‘type’ => ‘text’,
),- Here is result at backend:
- Step 2: Display new field at frontend
- To display this field at single video you should use child theme as in this topic: https://harutheme.com/forums/topic/customize-wordpress-theme-using-child-theme/
- Step 3: Add your CSS code in child theme or Theme Options -> General Settings -> Custom CSS
- Hope this will help you to make your work better.
**********
Best regards,
HaruTheme
-
This topic was modified 5 years, 7 months ago by
admin.
-
This topic was modified 5 years, 7 months ago by
admin.
-
This topic was modified 5 years, 7 months ago by
admin.
-
This topic was modified 5 years, 7 months ago by
admin.
-
This topic was modified 4 years, 5 months ago by
admin.
-
This topic was modified 4 years, 5 months ago by
admin.
-
This topic was modified 4 years, 2 months ago by
admin.
November 3, 2018 at 5:10 pm #2203I added a Metabox to the single Film and copied it to the child theme (using the same structure).
1. It does not show up in neither the backend nor frontend.
2. I directly added it to the Haru Circle Theme, it only appears in the backend.
Could you please tell me what did I miss?
here is my code:
array(
‘id’ => ‘haru_film’ . ‘_director’,
‘name’ => esc_html__( ‘Writer’, ‘haru-circle’ ),
‘desc’ => esc_html__( ‘Writer of Film.’, ‘haru-circle’ ),
‘type’ => ‘post’,
// Post type
‘post_type’ => ‘haru_director’,
// Field type, either ‘select’ or ‘select_advanced’ (default)
‘field_type’ => ‘select_advanced’,
‘placeholder’ => esc_html__( ‘Select Writer’, ‘haru-circle’ ),
// Query arguments (optional). No settings means get all published posts
‘multiple’ => false,
‘query_args’ => array(
‘post_status’ => ‘publish’,
‘posts_per_page’ => – 1,
),
),Here is how I developed the structure in child theme.
https://prnt.sc/ldzb0lDo I need to add some CSS (actually I don’t need to change anything about css) ?
I am sorry to bother you a lot, but I really need help. Thank you.
November 6, 2018 at 1:45 am #2224Hi,
Please copy the code you have added and the result at backend.
The code you have added have same id with existed other id.
So maybe it will doesn’t work.
‘id’ => ‘haru_film’ . ‘_director’,
Example change to:
‘id’ => ‘haru_film’ . ‘_writer’,
Please change this and also you need know a little about PHP to show new field.
Example in child theme you need show it like this:$film_writer_id = get_post_meta( get_the_ID(), 'haru_film' . '_writer', true ); $film_writer = get_post( $film_writer_id ); $film_writer_link = get_post_permalink( $film_writer_id );
To show at any position like this:
<?php if ( isset($film_writer) && !empty($film_writer) ) : ?> <li> <span class="meta-label"><?php echo esc_html__( 'Writer', 'haru-circle' ); ?></span> <div class="meta-value"> <a href="<?php echo esc_url($film_writer_link); ?>"><?php echo $film_writer->post_title; ?></a> </div> </li> <?php endif; ?>
Hope this help!
November 6, 2018 at 6:50 pm #2235Thanks for replying.
I use the same ID(_director) is just because I really want to achieve the same content from that ID. I just want to add one more title.
Is there any easier way to do so?
If not, where can I add this code? To the function.php of child theme?
$film_writer_id = get_post_meta( get_the_ID(), ‘haru_film’ . ‘_writer’, true );
$film_writer = get_post( $film_writer_id );
$film_writer_link = get_post_permalink( $film_writer_id );Thank you very much.
November 7, 2018 at 8:39 am #2242Hi,
Please read tutorial carefully.
You need copy this template and edit it in child theme to make your customization keep up when you update our theme to latest version:
http://prntscr.com/lfct1c
the template path: wp-content/themes/haru-circle/templates/single/content-film.php
Hope this help!November 9, 2018 at 4:32 pm #2262Hi Ellie,
I have same issue do you find a solution ? on to add the code
$film_writer_id = get_post_meta( get_the_ID(), ‘haru_film’ . ‘_writer’, true );
$film_writer = get_post( $film_writer_id );
$film_writer_link = get_post_permalink( $film_writer_id );
many thanks for your help
FlavioNovember 10, 2018 at 10:19 am #2263Hi,
We’ll noticed and add Writer in next version!November 10, 2018 at 12:37 pm #2266It is a really a great news! Thank you very much.
November 10, 2018 at 12:38 pm #2267I have not solved this yet. Since the author would add this function to next version, let’s wait for it!
November 10, 2018 at 11:17 pm #2269Perfect !! in the meanwhile I have added many other field in the signle film working on the theme-metabox and content film, and seems to work!!!
November 12, 2018 at 3:55 am #2277Hi,
But with the Writer did we need single page for each writer? -
AuthorPosts
You must be logged in to reply to this topic.