user11652114
user11652114

Reputation:

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.

Upvotes: 2

Views: 380

Answers (1)

GMarco24
GMarco24

Reputation: 428

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');
}

Upvotes: 1

Related Questions