Conditional tag for all categories of a custom post type

There are a few concerns here in the registration of your custom taxonomy as from the comments on your OP, this is not your code, but a client’s code. Still, taxonomy and custom post type names should never contain hyphens, just underscores to separate words there are non valid arguments used like exclude_from_search and has_archive … Read more

is_front_page not working in functions.php

Even though this question may get down voted – because not enough information has been provided and it’s fairly easy to find tutorials elsewhere, I’ll help you out. In your functions.php file in your theme, you need to do this: add_action( ‘wp_enqueue_scripts’, ‘wp5849_scripts’ ); function wp5849_scripts() { if ( is_front_page() ) : wp_enqueue_style(‘TBDhome’, get_stylesheet_directory_uri() . … Read more

functions.php conditional tag only for custom post type

Try using get_post_type() instead: if ( is_single() && ‘post_type’ == get_post_type() ) { // Do something } The is_post_type() conditional is deprecated. But even when it existed, it returned true if the current post is any registered custom post type. It has been replaced with post_type_exists(). (More information on Post Type conditional tags.)

Current post’s author name in the author meta tag

You cad add it via functions.php with a hook, instead of inside the loop (you don’t really want to add a loop to header.php): function add_author_meta() { if (is_single()){ global $post; $author = get_the_author_meta(‘user_nicename’, $post->post_author); echo “<meta name=\”author\” content=\”$author\”>”; } } add_action( ‘wp_enqueue_scripts’, ‘add_author_meta’ );

Conditional check for front-end which includes ajax

DOING_AJAX and WP_ADMIN (this constant is checked within is_admin() ) are defined in admin-ajax.php and set tro true. Both are not very helpfull in this situation. Add a parameter to your ajax request if the request come from the front-end: <?php function my_action_javascript() { ?> <script type=”text/javascript” > jQuery(document).ready(function($) { var data = { action: … Read more

is_singular() not working if called via callback function of admin-ajax.php

An AJAX request is a new request to the server, and it is a request to admin-ajax.php. That is not a single post page. Any logic that depends on is_single() or any other page level template tags like it, won’t work. If your AJAX callback needs that sort of information you must pass it to … Read more

How do I conditionally enqueue script for CPT single post type with plugin?

Make sure your code runs in wp_enqueue_scripts action hook. Also checkout your script handle ‘owl.carousel.js’. In wp_script_is(), it is not the same than in the 2 later functions in which you enter it as ‘owl.carousel.min.js’. add_action( ‘wp_enqueue_scripts’, ‘enqueue_properties_scripts’ ); function enqueue_properties_scripts() { if ( ‘properties’ === get_post_type() ) { if ( wp_script_is( ‘owl.carousel.min.js’, ‘enqueued’ ) … Read more