简体   繁体   中英

How to add a class to a link in functions.php?

I have some php which has some links within it which I'd like to style and turn into buttons.

add_action('admin_menu', 'wpso_custom_links_admin_menu');
function wpso_custom_links_admin_menu() {
    global $submenu;
    $submenu['index.php'][] = array( 'Link One', 'read', 'https://www.example.com/' );
    $submenu['index.php'][] = array( 'Link Two', 'read', 'https://asdf.com/' );
}

The issue is that I'm not sure how or where to add a class here in order to style with css.

This should do:

add_action('admin_menu', 'wpso_custom_links_admin_menu');
function wpso_custom_links_admin_menu() {
    global $submenu;
    $submenu['index.php'][] = array( 'Link One', 'read', 'https://www.example.com/', '', 'my-class');
    $submenu['index.php'][] = array( 'Link Two', 'read', 'https://asdf.com/', '', 'my-class');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM