Conditionally print css style in WordPress

Use the function body_class() in your templates: <body <?php body_class(); ?>> This creates extra classes on the body element. Then filter its values in your functions.php: add_filter( ‘body_class’, function( Array $classes ) { if ( $GLOBALS[ ‘isBoxedLayout’ ] ) $classes[] = ‘isBoxedLayout’; return $classes; }); Now you can move all CSS declarations for that to … Read more

How to conditionally output to sidebar of each author’s archive and posts by each author?

As often the case, asking the question reveals the answer: Use global $authordata;. Fix php errors: == operator. Fix $rid=’445′, not $rid=445. Here’s the working code: add_action (‘genesis_before_sidebar_widget_area’,’user_testimonials’,10); function user_testimonials(){ if (is_author() || is_singular(‘post’)){ global $authordata; //using global $authordata is more direct $authorlogin = $authordata->user_login; //print_r( $authordata ); //to see everything if (is_author(‘author-1’) || ($authorlogin==”author-1″) … Read more

Conditional Tags – Multiple Categories

As Mayeenul said in the comment you can use: if($category[0]->name == ‘News’ || $category[0]->name == ‘home-news’) { … And to follow up on your comment about the title flashing in, this is because the jQuery is run after the browser has already rendered the content so there’s a brief moment when it’s shown before jQuery … Read more

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