has_category() for parent category

To do what you want, you’ll need to get a list of all the child categories of the category you want, and then check those. But you don’t need to write that list manually. You can use get_term_children() to get the IDs of the child and grandchild categories: $cat_id = get_cat_ID( ‘FAQ’ ); $children = … Read more

WordPress Single Conditional for Search Page

You could hook into the the_permalink filter and check for is_search() to conditionally modify the URLs of your search results to include some additional parameters that your single.php then checks for. Something like this (may require tinkering): add_filter( ‘the_permalink’, ‘wpse155331_the_permalink’ ); function wpse155331_the_permalink( $url ) { if ( is_search() ) { $url = add_query_arg( array( … Read more

Why is wp-login redirecting to the home page when I use this function?

So, first off, if you want to block access to wp-admin, why hook into something that fires on every page load? Hook into admin_init instead. And, as @MattSmath mentioned, edit isn’t a capability. edit_posts is. Also, admin_init only fires on admin pages, so you can remove is_admin() from your check. Your revised function: <?php add_action(‘admin_init’, … Read more

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