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 }
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.
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.
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
Take a look at the is_admin() conditional tag: function wpse106895_dummy_func() { if ( ! is_admin() ) { // do your thing } } add_action( ‘some-hook’, ‘wpse106895_dummy_func’ ); is_admin() returns true, if the URL being accessed is in the dashboard / wp-admin. Hence it’s negation (via the not operator) is true when in the frontend. Update, … Read more