S
S
Sergey Burduzha2018-06-23 09:53:05
WordPress
Sergey Burduzha, 2018-06-23 09:53:05

How do I add a custom field for the Carbon Fields plugin for my post type?

I created my own type of portfolio posts and in it I will store the work from the portfolio.
Now I need to have a custom field of the Carbon Fields 2.2 plugin appear on the posts page .
5b2ded9bcd9e2415434076.jpeg
First I tried to add it. It didn't work. Then I tried through associations
where('post_type' = 'portfolio')

Container::make('post_meta', 'Контент страницы Портфолио')
    ->add_tab('Ссылка на работу', array(
        Field::make( 'association', 'crb_association' )
            ->set_types( array(
                array(
                    'post_type' => 'portfolio',
                )))
            ->set_required(true)
    ));

Or am I doing something wrong?
I have already displayed the records on the page, it remains to add a field in the admin panel.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Burduzha, 2018-06-23
@serii81

Decided as follows

Container::make( 'post_meta', 'Портфолио' )
    ->where( 'post_term', '=', 'portfolio')
    ->add_tab('Ссылка', [
        Field::make( 'text', 'portfolio_link', 'Ссылка на портфолио')
    ]);

Associations are needed when custom fields need to be added to multiple post types.
But it didn’t work, because I stupidly forgot to include the file in function.php
5b2df311d0d27583972442.jpeg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question