php return username of currently viewed author profile

On an author archive page (assuming the plugin uses the core archives) get_queried_object() will return the WP_User object for the author. Something like: $author = get_queried_object(); if (is_a($author, ‘WP_User’)) { var_dump($author->data); } You should see the login, nicename, and display name in there. Use what you need.

Search by Attachment ID

The WP_Query class can match IDs as well as search terms. An idea would be to use the pre_get_posts action to detect if the search term is numeric and, if it is, set the query to work with attachments while passing the search as the ID. function wpse223307_allow_search_by_attachment_id( $query ) { //Only alter the query … Read more

How can I exclude a specific ID from this line of code?

On a seperate note, ‘caller_get_posts’ was deprecated in version 3.1 – use ‘ignore_sticky_posts’ with a boolean argument instead. ‘exclude’ is not a query argument so WordPress ignores it. Post exclusion via query is done using the key ‘post__not_in’ with a single post ID or array of IDs instead. However as @vancoder points out, the argument … Read more

Get Image Having the ID [closed]

Put the below code in your functions.php and then you can use this [get_image_by_id id=”your-image-id”] shortcode to get the image add_shortcode( ‘get_image_by_id’, ‘the_dramatist_get_image_by_id’); function the_dramatist_get_image_by_id($atts) { return wp_get_attachment_image($atts[‘id’]); } Here “your-image-id” is numeric ID of the image. Hope that helps.

Is it possible to restrict access to specific pages in the admin area based on the page slug?

So following from the comment discussion, a sufficient answer on another StackEx question goes like this: 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(’21’,’22’,’23’); } } The only part that’s terribly important to us is the array of post IDS. The problem is … Read more