Returning Variables back into a template

There’s filters for that. Example: add_filter( ‘template_filter’, ‘wpse_102706_filter_callback’, 10, 2 ); function wpse_102706_filter_callback( $defaults, $case ) { $args = wp_parse_args( array( ‘some_key’ => ‘some_modified_value’ ), $defaults ); return $args } Then in your template just add in the defaults: apply_filters( ‘template_filter’, array( ‘some_key’ => ‘default_val’ ), ‘single’ ); More info in Codex about the Plugins … Read more

Calling a function from functions.php in custom page/ blog post

You could use add_shortcode if you want to use it within the editor. function footag_func() { return “Test”; } add_shortcode( ‘footag’, ‘footag_func’ ); And then use [footag] in your editor. Or Use code like this in functions.php and add a conditional tag add_action( ‘loop_start’, ‘your_function’ ); function your_function() { if ( is_singular(‘post’) ) { echo … Read more

loop not showing up when using a custom page template

You haven’t created a query to return your post index results. Let me back up… In WordPress something called the “Main” query runs very early in the page load, and well before your template files load. That query retrieves the posts to display and also (more or less) determines which template file to use to … Read more

how to show all post in my page-grid.php template page

<?php $args = array( ‘post_type’ => ‘put your custom PostType name here’, ‘posts_per_page’ => ‘-1’ ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); // Contents of the queried post results go here. } } // Restore original post data. wp_reset_postdata(); ?>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)