wp_head hook by page ID [closed]

If you want to use different meta tags for different pages I recommend you to use custom field values. If you prefer to do it with conditional functions, try this: add_action( ‘wp_head’,’carlos_head_meta_page’ ); function carlos_head_meta_page() { if ( is_page(‘4’) ) { $description = ‘tag1’; } else { $description = ‘tag2’; } ?> <meta name=”description” content=”<?php … Read more

WordPress conditionals not working

The problem is that you’re wrapping your add_action() calls inside of the conditionals, but at the point at which those add_action() calls are executed, neither the query nor the query conditionals are available yet. Solution: put the conditionals inside the callbacks: function faq_start_shortcode( $atts, $content = null ) { if ( is_single() || is_page() ) … Read more

Need help with else if statement

You should familiarize yourself with PHP, but if you want a default color ( assuming the code below already works ) you could do: <?php if ( in_category( ‘News’ )) : ?> <div class=”green”> <?php elseif ( in_category(‘Blog’)) : ?> <div class=”orange”> <?php else : ?> <div class=”pink”> <?php endif; ?>

Post tags show outside loop?

The code is tested and working fine. Place this code <?php $posttags = get_the_tags(); if( ! empty( $posttags ) ) : $tags = array(); foreach($posttags as $key => $value){ $tags[] = $value->name; } ?> <meta name=”keywords” content=”<?php echo implode( ‘,’, $tags ); ?>,test”/> <?php endif;?> instead of <meta name=”keywords” content=”<?php the_tags( ”, ‘,’, ” );?>test<?php … Read more

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