How I can echo some content based on current tab in my theme options. My tabbed theme option page has these tabs TAB1, TAB2, TAB3

I want to display a message on TAB2. The theme options page slug is /wp-admin/admin.php?page=options&tab=tab_1

I tried with

function show_message(){

if( isset( $_GET['tab'] ) ? $_GET['tab'] : 'tab_2' ){
echo 'This message';
echo 'That Message';

Your PHP logic is slightly off - you need to check the value of $_GET['tab']. At the moment you're saying "if $_GET['tab'] or 'tab_2'", which will always evaluate true:

if ( isset( $_GET['tab'] ) && $_GET['tab'] === 'tab_2' )
  • Thanks but it did not also help.. I also tried with this with no luck if (isset($_GET['page']) && $_GET['page'] == 'options' && isset( $_GET['tab'] ) && $_GET['tab'] === 'tab_2' ){ – Ayanize Feb 12 '16 at 13:00
  • Use the hook admin_notices instead of admin_head – TheDeadMedic Feb 12 '16 at 13:01
  • :( did not help.I think I am not getting the current screen of the the targeted tab. – Ayanize Feb 12 '16 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.