Community Forums › Forums › Archived Forums › General Discussion › genesis_unregister_layout is not working
Tagged: 3rd parameter, add_action, priority
- This topic has 5 replies, 3 voices, and was last updated 7 years ago by seancwalsh.
-
AuthorPosts
-
March 2, 2017 at 10:40 am #202347seancwalshMember
Hey,
I am trying to learn how to build a genesis child theme from scratch. I am trying to remove some of the layout options, but it does not work and I cannot figure out why. Here is my code in functions.php:
function scratch_setup() { define('CHILD_THEME_NAME', 'Scratch'); define('CHILD_THEME_URL', 'http://github.com/cdils/scratch'); define('CHILD_THEME_VERSION', '1.0.0'); //Add HTML5 Markup Structure add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) ); //Add viewport meta tag for mobile browsers add_theme_support( 'genesis-responsive-viewport' ); //Add theme support for accessibility add_theme_support( 'genesis-accessibility', array( '404-page', 'drop-down-menu', 'headings', 'rems', 'search-form', 'skip-links', ) ); //Add theme support for footer widgets add_theme_support('genesis-footer-widgets', 3 ); //unregister layouts that use secondary sidebar genesis_unregister_layout( 'content-sidebar-sidebar' ); genesis_unregister_layout( 'sidebar-sidebar-content' ); genesis_unregister_layout( 'sidebar-content-sidebar' ); }
March 2, 2017 at 12:00 pm #202352Victor FontModeratorWhere are you calling the function scratch_setup()? And why are you using that function? There's no need to wrap the code in a function.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?March 2, 2017 at 7:55 pm #202382seancwalshMemberHi Victor,
Thanks for your response. I am calling the function on the line above where I have declared it -
add_action ( 'genesis_setup', 'scratch_setup' );
Good question - I am actually following a tutorial at the moment and that is how it is done there. Whilst troubleshooting, I tried to move this code before and after this function, but it caused the site not to load, but I cannot yet figure out why.
Thanks
P.s - please excuse my ignorance! I have been editing php files in Genesis for a while now, but I have just started trying to write the code.
March 2, 2017 at 8:07 pm #202384seancwalshMemberI have fixed the issue. It was an issue with the code for calling the function as you suggested. I needed to add 15 to the end of the function call. I am not 100% why this works. Something to do with the order in which the function is called?
add_action ( 'genesis_setup', 'scratch_setup', 15 );
Thanks for your help.
March 2, 2017 at 8:54 pm #202386Brad DaltonParticipantUsed to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
Default value: 10
March 2, 2017 at 9:17 pm #202387seancwalshMemberGreat. Thank you.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.