Categories
WordPress

Identifying Custom Templates in WordPress

Sometimes, particularly when you’ve taken over the development of an existing WordPress-based website, its handy to be able to tell which of the custom templates in the theme folder are actively in use and by which pages. The following SQL query gives you that information.

SELECT p.ID, p.post_title AS Page, p.post_status AS Status, m.meta_value AS Template
FROM wp_posts p
LEFT JOIN wp_postmeta m ON p.ID = m.post_id
WHERE m.meta_key = '_wp_page_template'
ORDER BY p.post_title
Categories
WordPress

Hiding Disqus Comments

While the Disqus commenting system may be fine for standard post types, sometimes clients don’t wish to use them on┬áspecific custom post types. Previously (c. 2013), the following code worked for me…

add_filter( 'the_content' , 'dsq_comments_template_remove' );

function dsq_comments_template_remove( $content ) {
	global $post;

	if ( function_exists( 'dsq_comments_template' ) && 'post' != get_post_type( $post ) ) {
		remove_filter( 'comments_template', 'dsq_comments_template' );
	}
	
	return $content;
}

Now I have to use this code:

add_filter( 'comments_template' , 'dsq_comments_template_remove', 1 );

function dsq_comments_template_remove( $file ) {
	if ( 'question' == get_post_type() ) {
		remove_filter( 'comments_template', 'dsq_comments_template' );
	}

	return $file; 
}

Source: How to Disable Disqus on Custom Post Types in WordPress