Way to check if we are in Theme Customizer mode? [duplicate]
As in this question: How to execute conditional script when on new customize.php (Theme Customize) screen global $wp_customize; if ( isset( $wp_customize ) ) { // do stuff }
As in this question: How to execute conditional script when on new customize.php (Theme Customize) screen global $wp_customize; if ( isset( $wp_customize ) ) { // do stuff }
You have a basic mistake in your code. The following code if ( !is_page(‘my-page’) ) { means that if you are not on that page, deregister the scripts. Have a look at the php operators ! -> Not !$x True if $x is not true Also, why not exclude this specific page when you initially … Read more
Your conditional logic makes sense as well but you’re probably looking for this: if ( ‘page’ == get_option(‘show_on_front’) ) { // do something } Hint: You can append options.php to the WordpPress admin url like this: http://www.example.com/wp-admin/options.php to see all options. ( that’s where I found the answer for you .)
Regarding the posts_orderby, posts_where, posts_join and posts_clauses hooks, the current \WP_Query object is available through the second input argument. These are the relevant parts from the \WP_Query class: $orderby = apply_filters_ref_array( ‘posts_orderby’, array( $orderby, &$this ) ); $where = apply_filters_ref_array( ‘posts_where’, array( $where, &$this ) ); $join = apply_filters_ref_array( ‘posts_join’, array( $join, &$this ) ); … Read more
<?php if( is_front_page() ) : ?> is_home relates to the posts page according to your reading settings. is_front_page always returns true on the front page.
Sub-categories use the regular category archive page by default. There is no function such as is_subcategory. But you can write your own. Here is an example: This will check if the current page is a sub-category. Or if you pass an ID it will check if the ID is a subcategory. function is_subcategory( $cat_id = … Read more
you can use this for <?php global $post; if( $post->ID == 346) { ?> <!– do your stuff here –> <?php } ?> you can use this anywhere either in header or anywhere else.
added_post_meta seems like a good time to hook into a new image. Not only is the default meta already set but the function gives you the $post_id along with $meta_value which holds the attachment metadata. From there you can get all the fields and set the ones you want. add_action(‘added_post_meta’, ‘wpse_20151219_after_post_meta’, 10, 4); function wpse_20151219_after_post_meta($meta_id, … Read more
Did you check what part of is_front_page() is causing it to return false? I could reproduce the problem by following the setup from the trac ticket. In my case inside this function the call to is_page() was returning false. I guess this is due to using $wp_query->set() for page_id and is_page is only causing the … Read more
WordPress coding standards for PHP does not state anything about this, and there is no other standard, so it’s up to developers to choose one way or another. I have to say that the 2 methods have different approaches; while the first contains conditional logic, the second is a conditional function declaration, which means that … Read more