Restrict admin access to certain pages for certain users

This code seems to work well for me (in functions.php): $user_id = get_current_user_id(); if ($user_id == 2) { add_filter( ‘parse_query’, ‘exclude_pages_from_admin’ ); } function exclude_pages_from_admin($query) { global $pagenow,$post_type; if (is_admin() && $pagenow==’edit.php’ && $post_type ==’page’) { $query->query_vars[‘post__not_in’] = array(‘123′,’234′,’345’); } }

How to add a specific widget to only 1 page?

It depends on where you want to show the widget. Let’s start with the widget area (sidebar) registration: add_action( ‘wp_loaded’, ‘wpse_76959_register_widget_area’ ); function wpse_76959_register_widget_area() { register_sidebar( array ( ‘name’ => __( ‘Widgets on page Sample Page’, ‘theme_textdomain’ ), ‘description’ => __( ‘Will be used on a page with a slug “sample-page” only.’, ‘theme_textdomain’ ), ‘id’ … Read more

Get top level page parent title

Found this way: if ( 0 == $post->post_parent ) { the_title(); } else { $parents = get_post_ancestors( $post->ID ); echo apply_filters( “the_title”, get_the_title( end ( $parents ) ) ); } Anyone got a better way please answer.

How do I convert a page’s title to lower case?

lowercasing the title If I’m understanding you correctly, you should be doing: strtolower(get_the_title()); or print strtolower(get_the_title()); if you want to display it. Below is an explanation as to why. the_title() vs. get_the_title() The function the_title() prints the current post’s title unless you pass false as its third argument. Unless you call it like: $title = … Read more

Hide page visual editor if certain template is selected?

add_action( ‘init’, ‘remove_editor_init’ ); function remove_editor_init() { // If not in the admin, return. if ( ! is_admin() ) { return; } // Get the post ID on edit post with filter_input super global inspection. $current_post_id = filter_input( INPUT_GET, ‘post’, FILTER_SANITIZE_NUMBER_INT ); // Get the post ID on update post with filter_input super global inspection. … Read more

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