wp enqueue style on specific page templates

If you plan to do a lot of WP development you should bookmark this page: http://codex.wordpress.org/Conditional_Tags The other answer works but the conditional relies upon your page slug (myurl.com/this-is-the-slug) never changing. A more reliable method (IMO), and one that fits this case, would be to use the is_page_template(‘example-template.php’) conditional check instead.

conditional menu with custom fields

This can be done by registering different menu location for different users and then update location according to the User type which user selected during the registration time. We need to add the given code to functions.php file of the theme. In this code we are registering custom menus. function custom_menus_registration() { register_nav_menus( array( ‘user_type_a_menu’ … Read more

Conditional concerning a selected tag not working

isset() checks to see if a variable is set, ie, has a value other than null. The way you’re using it will always return true because you’ve set $posttags to ‘animali permessi’, which is not null. I think you’re looking for the WordPress function has_tag() instead. if (has_tag( ‘animali permessi’, $post ) ) { $supplemento_animali … Read more

Content Restriction but allow public REST API

You can use the REST_REQUEST constant to detect if this is a REST request, and if it’s not, apply your filter(s). Example: add_filter( ‘the_content’, ‘wpse418531_use_excerpt’ ); /** * Replaces the content with the excerpt, unless this is a REST request. * * @param string $content The post content. * @return string The filtered post content. … Read more

Link from page to category posts

Instead of hard-coding the pages, categories and sidebars in your template file(s) you could consider registering a custom metabox to store the category relation (i.e. the category term ID) in the page post meta. This way you could make the sidebar handling dynamic. The first step would be to register, render and handle the saving … Read more

How to tie two conditions to one statement

You can do this: $ac_inc = get_the_author_meta( ‘ac_inc’, $post->post_author ); if (has_tag(‘aria condizionata’, $post) && !empty($ac_inc)) { $ac_inc=”<div class=”ac_inc”>”. $ac_inc .'</div>’; } But actually the double “if” statement would be more optimal, as you would only run ‘get_the_author_meta’ when needed: if (has_tag(‘aria condizionata’, $post)) { $ac_inc = get_the_author_meta( ‘ac_inc’, $post->post_author ); if(!empty($ac_inc)){ $ac_inc=”<div class=”ac_inc”>”. $ac_inc … Read more

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