I need use is_single in functions.php

is_single most likely only works inside of The Loop, and functions.php loads before you’re in The Loop. You could try something like this: add_action( ‘wp_head’, function(){ var_dump(is_single()); }); And now you see that is_single() returns true. EDIT: I was probably off for suggesting it only works inside The Loop, but there’s definitely better places for … Read more

is_front_page() variable not found

There are several issues with your code. is_front_page() is a PHP function, you need to call it within <?php ?>. The script need to be printed in HTML in order to make it work. Try this.. function wpse_363853_run_on_front() { ?> <script> window.addEventListener(“load”, function() { <?php if( is_front_page() ){ ?> console.log(“front page”); <?php } ?> }); … Read more

Sub-category single post styling?

Try this if statement instead: if ( is_category() && ( is_category( 59 ) || cat_is_ancestor_of( 59, get_queried_object_id() ) ) ) Update: To work for single posts: if ( is_single() && $terms = get_the_category( get_queried_object_id() ) ) { foreach ( $terms as $term ) { if ( $term->term_id == 59 || cat_is_ancestor_of( 59, $term->term_id ) ) … Read more

Conditional tags not working

instead of echoing your styles anywhere, you can hook your code at wp_head to add it in head or wp_footer to add it in your footer, see if it works for you, function my_custom_style(){ global $post; if ( !empty ( $post->post_name ) && $post->post_name == ‘events’ ){ ?> <style type=”text/css”> #main { background-image: none; } … Read more

How to show only the most recent post on my custom post type archive?

You could just alter the main query for your custom post type archive with pre_get_posts(). Code: function wpse124228_alter_ppp_order_for_mycpt( $query ) { if ( ! $query->is_main_query() || is_admin() ) return; if ( is_post_type_archive( ‘mycpt’ ) ) { //Only display 1 post on mycpt archive $query->set( ‘posts_per_page’, 1 ); //Most recent/current $query->set( ‘orderby’, ‘date’ ); $query->set( ‘order’, … Read more

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