Check IF is a “single product page” and Check the “role” for a Redirect

Here is the result that works, I put in the condition : is_product() to check if is a single product page. And I changed in the add_action() : admin_init by wp function cm_redirect_users_by_role() { $current_user = wp_get_current_user(); $role_name = $current_user->roles[0]; if ( is_product() ){ if ( $role_name !== ‘customer’ && $role_name !== ‘shop_manager’ && $role_name … Read more

How to detect single.php (but not single-portfolio.php)?

You can use the following instead, if (is_singular(‘post’)) { //your code here… } Where by is_singular is the WordPress API conditional function for testing for the existence of a post type. You can also pass an array of post types if you wish. http://codex.wordpress.org/Function_Reference/is_singular

Custom post type single page returns 404 error

You should set your publicly_queryable argument to true when registering your custom post type. TAKE NOTE: Add flush_rewrite_rules(), refresh the page once or twice and REMOVE IT IMMEDIATELY. You SHOULD NOT keep flush_rewrite_rules() unless under the provisions as in the codex. this is an expensive operation so it should only be used when absolutely necessary

How to disable the single view for a custom post type?

METHOD 1: Redirect to a custom URL for single view, archive page is still publicly accessible. You can use template_redirect hook to redirect for a custom post type, you can use any other URL you want to in place of home_url() and the error code in other argument. <?php add_action( ‘template_redirect’, ‘wpse_128636_redirect_post’ ); function wpse_128636_redirect_post() … Read more

techhipbettruvabetnorabahisbahis forumutaraftarium24edueduseduedueduedueduseduedusedu