get_template_part not working with ajax

I loaded some contents by ajax, When i try something like this: $resp = array( ‘success’ => true, ‘data’ => ‘the content here’ ); it’s working without any issues but if i used something like this: $resp = array( ‘success’ => true, ‘data’ => get_template_part( ‘templates/update’, ‘profile’ ) ); it gives me SyntaxError: JSON.parse: unexpected … Read more

get_template_part inside get_template_part?

Ever tried this? // template file do_action( ‘my_hook’ ); // ex. functions.php function my_hooked_template_part() { get_template_part( ‘my_loop_part_file’, ‘default’ ); } add_action( ‘my_hook’, ‘my_hooked_template_part’ ); // my_loop_part_file-default.php get_template_part( ‘query’, ‘default’ ); if ( have_posts() ) { while ( have_posts() ) : the_post(); etc. // query-default.php get_posts( array( ‘whatever’ => ‘and_so_on’, ) ); Maybe it’s my setup, … Read more

Single Page WordPress Theme – Using page templates

Well I am lost, its late and I have been searching google all night. Heres the problem I am running into. I am trying to create a singe page website using wordpress “pages”. How I have initially setup the theme is there are several page templates for ex (‘page-contact.php, page-gallery.php, page-map.php etc.’). Each of these … Read more

get_template_part execute with ajax

I would like to get template part with AJAX. This template part – more-images.php contain of source some wp php and html. I read AJAX is build in WP. So I put code below to my theme files. My code: functions.php function get_img() { ob_start(); get_template_part(‘more’, ‘images’); die(); ob_clean(); } add_action( ‘wp_ajax_get_img’, ‘get_img’ ); add_action( … Read more

Get template part vs locate template function

I’m in single.php where I’m trying to get related-posts.php template. The problem is that when using get template part the related-posts.php isn’t getting custom taxonomy name from single.php in wp_Query. The solution is getting the wp post terms once again in related-posts.php in order to use get_template_part. But technically it shouldn’t be required since parent … Read more

How can I see what template parts are being called for rendering the viewable page?

I have a theme where the developer used get_tempalate_part() a lot, and these parts are scattered across theme subdirectories as well as in directories in a plugin that was created to assist with the theme. Here is the code I’m using to understand the primary template being called (the parent template, for lack of better … Read more

Pass a variable to get_template_part

In category-about.php I have <?php /** * The template for displaying the posts in the About category * */ ?> <!– category-about.php –> <?php get_header(); ?> <?php $args = array( ‘post_type’ => ‘post’, ‘category_name’ => ‘about’, ); ?> <?php // How to put this part in get_template_part ? $cat_name = $args[‘category_name’]; $query = new WP_Query( … Read more