Search
 
SCRIPT & CODE EXAMPLE
 

PHP

send variable to 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'];
Comment

PREVIOUS NEXT
Code Example
Php :: logout in laravel 
Php :: yii2 redirect back 
Php :: php get hour 
Php :: php remove all but numbers 
Php :: laravel latest() 
Php :: php read xml from url 
Php :: witherrors laravel 
Php :: make a seeding file in laravel 
Php :: php calculate percentage 
Php :: seed date laravel 
Php :: dynamic alert php 
Php :: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `users` add index `users_userable_type_userable_id_index`(`userable_type`, `userable_id`) 
Php :: wordpress print post data 
Php :: array merge php 
Php :: php 7 to php 8 in ubuntu 20.04 
Php :: php escape special characters 
Php :: php format datetime 
Php :: php sleep milliseconds 
Php :: Internal error: xmlSchemaXPathProcessHistory, The state object to be removed is not the first in the list. 
Php :: Extract images from a folder in php 
Php :: remove html from string php 
Php :: header.php file how to fetch in index.php file in wordpress 
Php :: convert 1 digit to five digits laravel 
Php :: Mask credit card number in PHP 
Php :: wordpress acf get checkbox options 
Php :: ternary operator laravel blade 
Php :: take fraction of number in laravel 
Php :: array_intersect php 
Php :: Call to undefined function mysql_connect() 
Php :: php Error!: could not find driver 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =