Search
 
SCRIPT & CODE EXAMPLE
 

PHP

get_template_part parameters

//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'];
Comment

PREVIOUS NEXT
Code Example
Php :: yii2 redirect back 
Php :: xml to object php 
Php :: apache htaccess read from /public 
Php :: php milliseconds 
Php :: pdo fetch 
Php :: php move file 
Php :: doument root phpp 
Php :: how to print query in laravel 
Php :: yii2 advanced nginx 
Php :: php copy url 
Php :: get logged in user name yii2 
Php :: php string max length 
Php :: laravel log permission denied mac 
Php :: get domain from url cakephp 
Php :: phpmailer with laravel 
Php :: laravel blade date format 
Php :: php get hdd serial number 
Php :: how to switch from php7.4 to php7.3 mac 
Php :: include a website in php file 
Php :: link js file in php 
Php :: check if input file is set codeigniter 
Php :: laravel save relationship to authorized user with parameter 
Php :: create custom domain in localhost xampp 
Php :: decimal to binary php 
Php :: Wordpress SVG Manually - function.php 
Php :: check if a string is url or not php 
Php :: phpmailer for wordpress 
Php :: use if in laravel blade 
Php :: phpspreadsheet applyFromArray wrap 
Php :: php client enable short tags 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =