How to get the site administrator/s by blog id

In shortcode form: /** * Shortcode for listing all admin users of a Multisite site * * Usage: [siteadmins blog=”1″] */ add_shortcode(‘siteadmins’, ‘wpse_55991_site_admins’); function wpse_55991_site_admins($atts, $content = null) { $site_admins=””; switch_to_blog( $atts[‘blog’] ); $users_query = new WP_User_Query( array( ‘role’ => ‘administrator’, ‘orderby’ => ‘display_name’ ) ); $results = $users_query->get_results(); foreach($results as $user) { $site_admins .= … Read more

Add social icons in a theme through custom admin menu

I did something similar on my site a while back. I’m sure you can tweak it to fit your needs. Under each article I have an author box with social media icons that link to their accounts. In content-single.php <?php if ( get_the_author_meta(‘twitter’) ) : ?> <a href=”http://www.twitter.com/<?php the_author_meta(‘twitter’); ?>” title=”Twitter”><img src=”<?php bloginfo( ‘url’ ) … Read more

Add a Custom Class to Admin Menus

The following does the job: add_action( ‘admin_init’,’wpse_60168_custom_menu_class’ ); function wpse_60168_custom_menu_class() { global $menu; foreach( $menu as $key => $value ) { if( ‘Posts’ == $value[0] ) $menu[$key][4] .= ” custom-class-1″; if( ‘Pages’ == $value[0] ) $menu[$key][4] .= ” custom-class-2″; } } And if you want to inspect what the $menu contains, use this: add_action( ‘admin_init’,’wpse_60168_var_dump_and_die’ … Read more

Show admin help message across custom post type parent and child posts

You’ll need to check the $pagenow variable and the post type of the post being edited. It will look something like this: function wpse_75224_admin_notices() { global $pagenow; $is_edit_custom_post_type = ( ‘post.php ‘ == $pagenow && ‘my_custom_post_type’ == get_post_type( $_GET[‘post’] ) ); $is_new_custom_post_type = ( ‘post-new.php’ == $pagenow && ‘my_custom_post_type’ == $_GET[‘post_type’] ); $is_all_post_type = ( … Read more

How to publish page that can’t be detected by search engines?

How about something like this on your functions.php: add_action(‘wp_head’, ‘no_robots_on_uncategorized_posts’); function no_robots_on_uncategorized_posts() { if(in_category(‘uncategorized’)) { wp_no_robots(); } } This will output the following line of code on the header of your ‘uncategorized’ posts: <meta name=”robots” content=”noindex,nofollow” /> What this means is that even though search engines will see the page, they will be told to … Read more

Add filter-by-tag in the all posts admin console page

User ‘restrict_manage_posts’ filter to add another filter. Use the following code in functions.php function kc_add_taxonomy_filters() { global $typenow; // an array of all the taxonomyies you want to display. Use the taxonomy name or slug $my_taxonomies = array( ‘post_tag’ ); switch($typenow){ case ‘post’: foreach ($my_taxonomies as $tax_slug) { $tax_obj = get_taxonomy($tax_slug); $tax_name = $tax_obj->labels->name; $terms … Read more

Calling a shortcode in the backend

As you noticed, the plugin use an instance of the class TablePress_Frontend_Controller to render the shortcode. This instance is created by only on frontend requests, this is the reason why shortcode doesn’t work on backend. The function tablepress_print_table function use the TablePress_Frontend_Controller::shortcode_table method to render the table, and this is the reason why also that … Read more

Dashboard–> All Pages “How to create folders?”

There are no page folders in WordPress, though that’s a good idea. Create subpages; that will give you a visual hierarchy, an also an automatic “breadcrumb” hierarchy, if useful. But you will still be able to organize pages in menus any way you want. See https://codex.wordpress.org/Pages And/or use CMS Page Tree View http://wordpress.org/plugins/cms-tree-page-view/ And Simple … Read more