Answer the question
In order to leave comments, you need to log in
Wordpress & Timber (twig): admin side usage and usage doubts?
I’ve been working with Timber
for 2 days now and I’m quite satisfied, I don’t want to write pages as before, but there are a few things:
1) I don’t quite understand how to use timber on the admin side, for example, display the template in some custom section. I did not find any docks for this case, so I myself came up with this option:
function.php, code for adding a field in the user profile
add_action( "show_user_profile", "add_worker_profile_section" );
add_action( "edit_user_profile", "add_worker_profile_section" );
add_action( 'user_new_form', 'add_worker_profile_section' );
function add_worker_profile_section( $user ) {
$context['edit_user'] = new TimberUser( $user );
Timber::render('admin.twig', $context);
}
<h1>{{ edit_user.name }}</h1>
<input type="text" name="city" value="{{ user.get_field('_city') }}" placeholder="Город">
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question