Add below function in your child themes functions.php
//remove post title from breadcrumb
function be_remove_title_from_single_crumb( $crumb, $args ) {
return substr( $crumb, 0, strrpos( $crumb, $args['sep'] ) );
}
add_filter( 'genesis_single_crumb', 'be_remove_title_from_single_crumb', 10, 2 );
Friday, March 17, 2017
Wednesday, March 8, 2017
Remove Query Strings from Static Resources in Genesis
To Remove Query Strings from Static Resources in Genesis add below code snippet in theme's funtions.php file
function _remove_script_version( $src ){
$parts = explode( '?ver', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
This will help your site load faster
function _remove_script_version( $src ){
$parts = explode( '?ver', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
This will help your site load faster
How to show list of related posts below post in Genesis
To show related posts sorted using categories add below code snippet in Genesis child theme's fuctions.php file
function related_posts_categories() {
if ( is_single ( ) ) {
global $post;
$count = 0;
$postIDs = array( $post->ID );
$related = '';
$cats = wp_get_post_categories( $post->ID );
$catIDs = array( );{
foreach ( $cats as $cat ) {
$catIDs[] = $cat;
}
$args = array(
'category__in' => $catIDs,
'post__not_in' => $postIDs,
'showposts' => 8,
'ignore_sticky_posts' => 0,
'orderby' => 'rand',
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array(
'post-format-link',
'post-format-status',
'post-format-aside',
'post-format-quote' ),
'operator' => 'NOT IN'
)
)
);
$cat_query = new WP_Query( $args );
if ( $cat_query->have_posts() ) {
while ( $cat_query->have_posts() ) {
$cat_query->the_post();
$related .= '<li><a href="' . get_permalink() . '" rel="bookmark" title="Link to ' . get_the_title() . '">' . get_the_title() . '</a></li>';
}
}
}
if ( $related ) {
printf( '<div><h3>Related stuff:</h3><ul class="myrelated">%s</ul></div>', $related );
}
wp_reset_query();
}
}
add_action( 'genesis_after_entry_content', 'related_posts_categories' );
In above code :
function related_posts_categories() {
if ( is_single ( ) ) {
global $post;
$count = 0;
$postIDs = array( $post->ID );
$related = '';
$cats = wp_get_post_categories( $post->ID );
$catIDs = array( );{
foreach ( $cats as $cat ) {
$catIDs[] = $cat;
}
$args = array(
'category__in' => $catIDs,
'post__not_in' => $postIDs,
'showposts' => 8,
'ignore_sticky_posts' => 0,
'orderby' => 'rand',
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array(
'post-format-link',
'post-format-status',
'post-format-aside',
'post-format-quote' ),
'operator' => 'NOT IN'
)
)
);
$cat_query = new WP_Query( $args );
if ( $cat_query->have_posts() ) {
while ( $cat_query->have_posts() ) {
$cat_query->the_post();
$related .= '<li><a href="' . get_permalink() . '" rel="bookmark" title="Link to ' . get_the_title() . '">' . get_the_title() . '</a></li>';
}
}
}
if ( $related ) {
printf( '<div><h3>Related stuff:</h3><ul class="myrelated">%s</ul></div>', $related );
}
wp_reset_query();
}
}
add_action( 'genesis_after_entry_content', 'related_posts_categories' );
In above code :
- Change showposts number to control count of links shown in related posts
- Class myrelated is defined for the listing. This class can be used to style related posts appearance using CSS
How to change search box text in Genesis
To change search box text add below code snippet in Genesis child theme's functions.php file
add_filter( 'genesis_search_text', 'bg_search_input_text' );
function bg_search_input_text( $text ) {
return esc_attr( 'Search this site..' );
}
Add text of your choice instead of highlighted text above.
How to remove self pings in Genesis
Pingbacks or trackbacks are good in a way to showcase your content popularity. But self pingbacks are irritating when you have comment moderation enable in your setup.
Apart from showcasing pingbacks dont stand any value for SEO. If you want to disable them in your Gensis themes then add below code in functions.php file of child theme.
function no_self_ping( &$links ) {
$home = get_option( 'home' );
foreach ( $links as $l => $link )
if ( 0 === strpos( $link, $home ) )
unset($links[$l]);
}
add_action( 'pre_ping', 'no_self_ping' );
Apart from showcasing pingbacks dont stand any value for SEO. If you want to disable them in your Gensis themes then add below code in functions.php file of child theme.
function no_self_ping( &$links ) {
$home = get_option( 'home' );
foreach ( $links as $l => $link )
if ( 0 === strpos( $link, $home ) )
unset($links[$l]);
}
add_action( 'pre_ping', 'no_self_ping' );
How to remove emoji support in wordpress to load website faster
Emoji are small animated smiles which replaces text based emoticons like :-)
They look beautiful but they eats few of your bandwidth and hence load time when their support is loaded with webpage.
If you are concerned about your website speed, consider disabling them.
Add below function in your function.php file of child theme of Genesis Framework.
function bt_remove_emoji() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
add_filter( 'tiny_mce_plugins', 'bt_remove_tinymce_emoji' );
}
add_action( 'init', 'bt_remove_emoji' );
function bt_remove_tinymce_emoji( $plugins ) {
if ( ! is_array( $plugins ) ) {
return array();
}
return array_diff( $plugins, array( 'wpemoji' ) );
}
How to center align pagination in Genesis magazine pro theme
Pagination in Magazine pro theme (Genesis framework) is left aligned by default. To align it to center use below CSS code in additional CSS under Appearance > customize menu.
.archive-pagination {
text-align: center;
}
To add space between pagination number blocks in Magazine pro theme (Genesis framework) use below CSS code :
.archive-pagination li {
margin-left: 5px;
}
How to add affiliate link box below post in Genesis
You might have seen box below post which has social links, subscribe links or affiliate links. One can be seen on tecmint.com
To add such box in Genesis framework themes follow below process :
<div class="belowpostbox">
<h4 class="belowposthead">If you like out posts, then</h4>
<ul class="belowpost">
<li>Like us xyz</li>
<li>Subscribe to our newsletter</li>
<li>Buy from affiliate link</li>
</ul>
</div>
Now using CSS code you an decorate this box. We have defined belowpostbox div tag for it. Style this and you will see result as expected.
For example below CSS code will style box with blue color border and fill it with grey color. Also it will round edge corners of box.
.mybox {
border: 2px solid blue;
padding: 20px;
margin: 5px;
border-radius: 15px;
background-color: grey;
}
You can add style of your own choice.
To add such box in Genesis framework themes follow below process :
- Install Gensis Simple hooks plugin.
- You will see Gensis menu on left hand side column under WordPress admin panel.
- Navigate to Simple Hooks under it
- Enter below code in "genesis_entry_footer Hook"
<h4 class="belowposthead">If you like out posts, then</h4>
<ul class="belowpost">
<li>Like us xyz</li>
<li>Subscribe to our newsletter</li>
<li>Buy from affiliate link</li>
</ul>
</div>
Now using CSS code you an decorate this box. We have defined belowpostbox div tag for it. Style this and you will see result as expected.
For example below CSS code will style box with blue color border and fill it with grey color. Also it will round edge corners of box.
.mybox {
border: 2px solid blue;
padding: 20px;
margin: 5px;
border-radius: 15px;
background-color: grey;
}
You can add style of your own choice.
Subscribe to:
Posts (Atom)