Skip to content

Instantly share code, notes, and snippets.

@rgadon107
Last active January 10, 2017 19:00
Show Gist options
  • Save rgadon107/affe969751c19d7bfbcaa47d904bf2d7 to your computer and use it in GitHub Desktop.
Save rgadon107/affe969751c19d7bfbcaa47d904bf2d7 to your computer and use it in GitHub Desktop.
add_action('genesis_before_content', 'ystl_add_blog_title');
/**
* Add 'Yoga St. Louis Blog' title to 'genesis_before_content' hook.
*
* @since 1.0.0
*
* @param string $title HTML markup of blog title
*
* @return string Add title before blog on front page or archive post page.
*
*/
function ystl_add_blog_title($title) {
$title = '<a href="http://ystl.dev" id="ystl-blog-title" class="featured-content blog-title">Yoga St. Louis Blog</a>' . '<br />';
if ( is_front_page() || is_singular( 'post' ) ) {
echo $title;
}
else {
echo '';
}
}
'Replace above with code block below ======================================================='
add_filter('genesis_attr_content_sidebar_wrap', 'build_content_sidebar_wrap');
/**
* Add attributes to blog title using the `genesis_attr_{context}` filter
* in 'genesis/lib/functions/markup.php.'
*
* @since 1.0.0
*
* @param array $attributes An array of attributes to build the markup.
* @return array $attributes
*/
function build_content_sidebar_wrap( $attributes ) {
if ( ! is_front_page() || ! is_singular( 'post' ) ) {
return $attributes;
}
$site_url = get_site_url();
$attributes[‘open’] = ‘<a %>’;
$attributes[‘id'] = 'blog-title';
$attributes[‘class'] = ‘featured-content’;
$attributes[‘href=""’] = $site_url;
$attributes[‘title’] = ‘Yoga St. Louis Blog’;
$attributes[‘close’] = ‘</a>’;
return $attributes;
}
@rgadon107
Copy link
Author

rgadon107 commented Jan 10, 2017

// Final result:

add_action('genesis_before_content', 'render_blog_page_title_after_content_sidebar_wrap' );
/**

  • Render the blog page title on the front and post pages.

  • @SInCE 1.0.0

  • @return void
    */
    function render_blog_page_title_after_content_sidebar_wrap() {

    if ( is_front_page() || is_singular( 'post' ) ) {

    include( __DIR__ . '/lib/structure/views/blog-title.php' );
    

    }
    }

//Code included from view file (commented out for demonstration purposes):

Yoga St. Louis Blog

// Note: the php echo command in the view file was necessary to render the site url to the browser. The WP callback by itself
// returns an empty string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment