Code Snippet – Genesis Framework – Move Primary Sidebar
So I haven’t blogged in FOREVER! but hopefully will be doing so more often. One thing I’ve been wanting to do is post code snippets that are helpful to me as I work on client projects, so here’s the first snippet:
remove_action( 'genesis_after_content', 'genesis_get_sidebar' ); add_action( 'genesis_before_content', 'genesis_get_sidebar' );
This code is for use with the Genesis Framework for WordPress. I’ve used it on many recent client projects and like it, but sometimes it can be hard to figure out how to do something simple – in this case, I needed to move the primary sidebar div (#sidebar) above the content div (#content). As I was searching, all the sites suggested I used some variation of this code:
remove_action('genesis_sidebar','genesis_do_sidebar'); add_action('genesis_before_content', 'genesis_do_sidebar');
That was obviously enough for some people, but here’s the problem with the above code: it doesn’t move the sidebar div, it just removes the default content of the sidebar div. By default in Genesis, the primary sidebar div is structurally after the content div – but I needed it to be loaded first.
If this was helpful to you, let me know in the comments!