Toggle admin metabox based upon chosen page template

The best way to approach this situation is via JavaScript. That way, whenever the selected value changes, you can instantly hide/show the related metabox. Use wp_enqueue_script() in functions.php to load a custom JavaScript file in the admin area: add_action(‘admin_enqueue_scripts’, ‘my_admin_script’); function my_admin_script() { wp_enqueue_script(‘my-admin’, get_bloginfo(‘template_url’).’/my-admin.js’, array(‘jquery’)); } The script itself, which requires jQuery, simply hides … Read more

Row actions for custom post types?

When using custom post type you use the post_row_actions filter hook and check the post type to modify it only: add_filter(‘post_row_actions’,’my_action_row’, 10, 2); function my_action_row($actions, $post){ //check for your post type if ($post->post_type ==”feedbacks”){ /*do you stuff here you can unset to remove actions and to add actions ex: $actions[‘in_google’] = ‘<a href=”http://www.google.com/?q=’.get_permalink($post->ID).'”>check if indexed</a>’; … Read more

Setting $_SERVER[‘HTTPS’]=’on’ prevents access to wp-admin

Special thanks to user42826. According to the codex: If WordPress is hosted behind a reverse proxy that provides SSL, but is hosted itself without SSL, these options will initially send any requests into an infinite redirect loop. To avoid this, you may configure WordPress to recognize the HTTP_X_FORWARDED_PROTO header (assuming you have properly configured the … Read more

Disable dragging of meta boxes?

I had the same problem, and Google lead me here. Unfortunately none of these answers helped, but I ultimately figured out the answer, and it’s quite easy! First, enqueue a JavaScript file (I won’t rehash this process; there are many tutorials that can describe this process better than I). I hooked into admin_enqueue_scripts, and it … Read more

Admin Page Redirect

/** * Redirect admin pages. * * Redirect specific admin page to another specific admin page. * * @return void * @author Michael Ecklund * */ function disallowed_admin_pages() { global $pagenow; # Check current admin page. if ( $pagenow == ‘edit.php’ && isset( $_GET[‘post_type’] ) && $_GET[‘post_type’] == ‘page’ ) { wp_redirect( admin_url( ‘/post-new.php?post_type=page’ ) … Read more

Placing a Custom Post Type Menu Above the Posts Menu Using menu_position?

Positions for Core Menu Items 2 Dashboard 4 Separator 5 Posts 10 Media 15 Links 20 Pages 25 Comments 59 Separator 60 Appearance 65 Plugins 70 Users 75 Tools 80 Settings 99 Separator Parameter description for “menu position” $position (integer) (optional) The position in the menu order this menu should appear. By default, if this … Read more

How to restrict dashboard access to Admins only?

We can hook to the admin_init action and check if the user is an administrator by using the current_user_can() function to see if the current user can manage_options, which is something only an administrator can do. This code, when pasted into your functions.php file, will display a message when a non-admin tries to access the … Read more

Modal window from within WordPress admin

Give the anchor a class of thickbox and make sure that the thickbox script is enqueued on your admin page using add_thickbox add_thickbox(); and <a href=”https://wordpress.stackexchange.com/questions/48514/your url” class=”thickbox”>click here</a> You can see what add_thickbox does here: http://hitchhackerguide.com/2011/02/11/add_thickbox/

“Too many redirects” ONLY when trying to access wp-admin page

I found a solution that fixed my issue. Sources: A.) https://sharpten.com/blog/2018/01/17/wordpress-stuck-many-redirects-error-loop-using-ssl.html B.) (Sublink within A) https://wordpress.org/support/article/administration-over-ssl/ Excerpt: Adding the following lines of code at the end of my wp-config.php file resolved the redirect conflict. if (strpos($_SERVER[‘HTTP_X_FORWARDED_PROTO’], ‘https’) !== false) $_SERVER[‘HTTPS’]=’on’;

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