Redirect logged user depending on user role if he tries to access home page?

Try something like this. Also read about wp_redirect() too. function redirect_by_role(){ if (is_user_logged_in()) { $user = wp_get_current_user(); if (is_home()) { if ( in_array( ‘author’, (array) $user->roles ) ) { $redirect_url=””; wp_redirect($redirect_url, 301); exit; } elseif( in_array( ‘**another_role_here**’, (array) $user->roles ) ) { $redirect_url=””; wp_redirect($redirect_url, 301); exit; } } } else { // Do what you … Read more

WP_Query & shortcode : Return 3 articles from a category WordPress

The problem is your $contenu variable. Try: $contenu .= ‘<div class=”effect-jazz”>’.get_the_post_thumbnail().'<div class=”jazz-try”> <div class=”h3″><a href=”‘.get_permalink().'”>’.get_the_title().'</a></div> <p>’.get_the_resume(60).'</p><!– THIS FUNCTION NEEDS TO BE CREATED –> </div> </div>’; Do not use ; trailers when using inline php, ex <a href=”‘.get_permalink().'”>. Use the appropriate return functions: get_the_post_thumbnail() get_permalink() get_the_title() Create a return version of the_resume() function Do use the … Read more

I need to ‘wp_dequeue_script’ and ‘styles’ and ADD a bunch of other css and js

Using wp_enqueue_scripts You should use a proper hook to enqueue/dequeue your scripts, to ensure that it works flawlessly. A proper plugin/theme uses wp_enqueue_scripts to do this, so you should do the same. Wrap your code inside a function, and bind it to this action hook. Also, remember to set the priority to something that makes … Read more

How fix error in the WordPress loop?

You’ve set ‘posts_per_page’ => -1,, which means unlimited posts per page, but are checking $wp_query->max_num_pages > 1. There’s never going to be more than 1 page if you have unlimited posts per page.