Trimite variabilă la get_template_part

Exemple de cod

1
0

cum să treci id-ul prin partea șablonului get

<?php
get_header();

// etc.

// In the main template file
$users = new \WP_User_Query( [ ... ] );

foreach ( $users as $user )
{
    set_query_var( 'user_id', absint( $user->ID ) );
    get_template_part( 'template-parts/user', 'contact_methods' );
}
0
0

trimite variabilă la get_template_part

//NEW CLEAN way (WP 5.5.0 >=) of passing variables to template parts 

$data = array('foo'=>'bar');

//add your variables as a third parameter
get_template_part( 'template-parts/file', 'name', $data );

//In the template part itself: (IMPORTANT NOTE: the name of the variable has to be args)
echo $args['foo'];

În alte limbi

Această pagină este în alte limbi

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................