Category: Code snippets

  • Conditionally display Genesis Social Share, e.g. not on a specific category

    The Genesis Social Share plugin is one of the must have plugins for Genesis sites. See I wanted to display these icons (just like the ones on this post) except on posts in a specific category.  I had to read the plugin code to work this out. Fortunately the code is an example of beautifully […]

  • Conditionally remove header widget from Genesis

    Genesis comes with a header widget area built in. Occasionally you may want to remove this for specific pages. The following code snippet in functions.php will do the trick add_action( ‘genesis_meta’, ‘my_remove_hr’); function my_remove_hr() { if ( is_page( ‘privacy-cookies’ ) ) { unregister_sidebar( ‘header-right’ ); } } The if statement will need to be adjusted […]

  • Allow html in user description

    The WordPress user bio only allows a very restricted set html. Occasionally, it is desirable to be able to format the WordPress user bio with additional html.  Out of the box that is not possible. However to allow additional html in the WordPress user bio, like I have with some <p> and <br> to break […]

  • Coding jQuery safely in WordPress

    I keep forgetting the syntax so this is just to remind me. In WordPress you want to ensure you don’t get conflicts with jQuery so there is a safe way to code it jQuery(function( $ ) { // Your code using failsafe $ alias here… }); And if you want it when the DOM is […]

  • CSS styled slider buttons, with CSS triangles

    You can style slider buttons using css.   A simple clean style is arrows with a square box ( or a circle ). An example is like this  The code is like this <a href=”#”><div class=’arrow-wrap left’> </div></a> <a href=”#”><div class=’arrow-wrap right’> </div></a> Which sets up the links and a div per link then the css […]

  • Forcing a page layout conditionally in Genesis

    Often it is prudent to force a page layout, especially the home page. Within Genesis, the guidance is fairly scant   <?php //* Do NOT include the opening php tag //* Force content-sidebar layout setting add_filter( ‘genesis_pre_get_option_site_layout’, ‘__genesis_return_content_sidebar’ ); //* Force sidebar-content layout setting add_filter( ‘genesis_pre_get_option_site_layout’, ‘__genesis_return_sidebar_content’ ); //* Force content-sidebar-sidebar layout setting add_filter( ‘genesis_pre_get_option_site_layout’, […]