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 :: str_includes php 
Php :: setcookie php 
Php :: laravel created_at migration 
Php :: how to print array in laravel blade 
Php :: wordpress query orderby name 
Php :: unique value when two columns laravel migration 
Php :: unique validation on update laravel 
Php :: php get string before character 
Php :: php time format 
Php :: display exception in blade laravel 
Php :: how to add data to the request object in laravel 
Php :: get current page slug 
Php :: insert rows in migrations laravel 
Php :: allert in php 
Php :: sum multiple fields separately in laravel 
Php :: How to use php to set title 
Php :: debug query in moodle 
Php :: Wordpress Pagination for WP_Query 
Php :: php explode by tab 
Php :: get count of relationship table laravel 
Php :: isset submit in php 
Php :: laravel Post model for flat file CMS 
Php :: have_rows count acf php 
Php :: php sleep 1 second 
Php :: laravel current timestamp 
Php :: php code to check if variable is null 
Php :: a backwards counting forloop 
Php :: add a new column to existing table in a migration 
Php :: CORSS oauth/token lavarel 
Php :: php str_replace multiple 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =