You can use get_blog_details() to do it.
Use it the following way:–
function greeting() {
global $blog_id;
$current_blog = get_blog_details( $blog_id );
if ( 'one' == $current_blog->blogname ) {
echo 'hello';
} elseif ( 'two' == $current_blog->blogname ) {
echo 'goodbye';
}
}
Related Posts:
- Prevent “main” WPMU site_url() being returned in functions
- Implementing DNS Prefetching with WordPress
- Different functions file for each site in multisite installation?
- Delete pages and Create default pages for all new network sites
- Multisite, either change the name of sample-page or create new page
- Loop (iterate) through Multi-Site sub-sites (blogs)?
- Global functions on WPMU
- restore_current_blog required after switch_to_blog, if I use that in a function?
- Run function when WordPress new multisite is created or ACF field is updated
- Conditional Gravity Forms filter in WordPress Multisite
- Multisite Ajax serialize return error [object Object]
- Creating new blog on multisite programatically without hacks?
- How to get correct URLs in network wide menu (Multisite)?
- Multisite 404 on pages – rewrite error breaks database
- Has is_archived() for sites in a multisite changed with WP 4.7?
- Function that outputs second theme url
- dynamic site link for future migration in echo do_shortcode()
- wp_get_attachment_image_src returns image on main domain, false on subdomain
- Dashboard blocker on network multisite for specific user roles
- Members only function, but allow account activation [solved]
- Competing Login Redirects – Need to be Combined?
- Adding a class to the body of an inactive site using multisite
- Run function from parent on child site
- Ads Only at one website inside multisite network – code error
- Different ads on every website on multisite environment
- Add class to menu items of one specific menu (nav_menu_css_class)
- Filter the query ONLY for the search results page
- How to add attributes to a shortcode
- Using add_filter() in Widgets
- Customize WordPress Media Manager – Media Window
- How can I add an extra WooCommerce hook
- Add attribute to link tag that’s generated through wp_register_style?
- How to override functions.php in child theme?
- Wrap gutenberg block ‘div’ in other elements/extra HTML
- Remove Page Title from Static Frontpage
- Default or Preset Content for Custom Post Types
- Problem using is_single() to enqueue script from functions.php
- If function exists, and array is met, echo function?
- Breadcrumb how i can display page title with parent > child title with permalink ? any Idea
- change a post status when users update posts?
- How often is functions.php loaded?
- display public excerpt for private post
- automatically adding submenu items
- Functions.php: If its single?
- Remove Menu Page Giving Error
- How to add another user to this remove_menu function?
- Display height and width properties with the_post_thumbnail() or related function
- Cleaner way to access custom fields in code?
- Dequeue script in template isn’t working
- How do I call wp_mail from HTML?
- wp_link_pages: display current page number only if has multiple page breaks?
- RSS Feed has no styles in chrome – function to add one?
- change default option in wp_dropdown_categories
- Display a text message if the shortcode is found?
- Adjust which tempalte a page uses with a function?
- How to change menu icon which is overriden (i.e. by WooCommerce) [closed]
- How to store / access files in child theme folder
- WordPress Content Security Policy and Subresource Integrity
- How to use IF Statement in WordPress?
- Woocommerce Storefront WordPress Ignore Media Gallery Images and use External 3rd Party Host
- Display trackbacks separately from comments in twentyeleven
- modify a function filter
- Change the slug of a particular page every x hours
- Use of undefined constant bloginfo
- How would go about if I just want a temporary function?
- How do I edit wp_head and/or functions.php to remove rss-feed which isnt used and dont validate?
- Accepted arguments value in hook functions
- Best practices for multiple Custom Feeds functions
- Print Post Parent Title
- Which action hook to use for function?
- Change size and crop medium_large images
- Ninja form Redirect depending on text field content [closed]
- Display Password Protected external RSS in wordpress template
- How to automatically remove links from WordPress Biographical Info?
- Custom HTML in specific category single page and its descendant categories
- How to change login labels
- Get the link for RSS item to display in feed
- Shortcode pagination not advancing
- Modify a function without editing template
- How to hide unused profile fields?
- Commenter should see only his comments in wordpress
- translate the_title() with .po & .mo
- Right way to update widget on dynamic new input field
- Problem only while using require_once() within functions.php
- Override widget in function WordPress
- custom rss templete
- How to change or add user role after getting post request data about pay? [closed]
- How can i disable auto save & revisions with `function.php` in wordpress?
- Remove elementor header and display default theme header
- How to force field validation first, then its values saved durning edit profile?
- Filter out other users comments. Visualize only own comments and editor role users’ comments
- How to properly remove style for non logged in and front page only
- Move ‘current-menu-item’ class on #adminmenu li from Posts to Pages for Taxonomy Edit Screen
- Insert image in WordPress with HTML5 tag and caption function
- How to construct function for applying filter?
- WordPress on AWS Auto scaling and ELB giving 503
- enqueue styles for only mobile wp
- WordPress converts media extention URL automatically to video player
- Automatically include all php files in a child theme directory
- WordPress PHP Conflicting User Sessions