Conditional Statement – Best Way to Remove Nav on Contact Page

You could try putting this code in your functions.php function remove_contact_nav( $nav_menu, $args ){ if( is_page_template(‘template-contact.php’) || is_page( ‘contact’ ) ) { $nav_menu = null; } return $nav_menu; } add_filter( ‘wp_nav_menu’, ‘remove_contact_nav’, 11, 2 ); The if condition need to be modified as per your template name or the second condition would also do if … Read more

conditional statement for custom taxonomy

I’m pretty sure you shouldn’t use negation in your conditions… If you check ! is_tax… it will be true not only for other taxonomy pages, but also for singular pages, and any other… So it should look like this: <?php if ( is_tax(‘taxonomy-name’,’taxonomy-one’ ) ) {?> <div class=”test” style=”color: red”><?php the_field(‘field_name’); ?></div> <?php } elseif … Read more

Conditionally load child themes

WordPress use an option to store the current active child theme. This option is named ‘stylesheet’. Using the filter ‘pre_option_{$option_name}’ you can change every option getted by WP. So, in your case you should hook the ‘pre_option_stylesheet’ filter, use some logic to retrieve current season and return the child theme you want. This workflow should … Read more

Conditionally set post_content in wp_insert_post

I can’t help but think I am missing something but what seems like the obvious answer is to alter your $create_pages array: $create_pages = array( ‘one’ => ‘content for one’, ‘two’ => ‘content for two’, ‘three’ => ‘content for three’ ); foreach ($create_pages as $title => $content) { $add_pages = array( ‘post_title’ => $title, ‘post_content’ … Read more

Query posts by content lenght

I want to suggest you another approach. You can set a meta when you saving a post if its content is less than 140 chars, so then you can simply runs a simple meta query. add_action( ‘save_post_post’, function( $id, $post ) { if ( $post->post_status !== ‘publish’ ) { return; } if ( strlen( $post->post_content … Read more

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