Detect if current page is front page within custom query

Marius, I have been in this situation before as well. Haven’t found a good solution though. Answer provided by Laxmana won’t work as the $isFrontPageOrSearch wont be accessible inside the template-part file. Although using the approach provided by Laxmana, you could be using PHP include(locate_template(‘your-template-name.php’));, instead of using get_template_part function. Then the variable would be … Read more

get_template_part based upon post’s category

It looks like the single quotes are giving you problems. Replace: get_template_part( ‘templates’, ‘$childcat->slug’ ); with: get_template_part( ‘templates’, $childcat->slug ); Note that double quoted strings in PHP can parse variables, not single quotes. Also check out the curly syntax in the PHP docs in the variable parsing section.

add active class based on permalink and url

For the left side you could do this, <?php $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 10, ‘paged’ => get_query_var(‘paged’) ? get_query_var(‘paged’) : 1, ); $loop = new WP_Query( $args ); // add custom function before loop, so you can apply excerpt filter only to this case do_action(‘my_custom_pre_loop_action’); // is url parameter set, if … Read more

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