I've been trying to work on this little thingy for almost a full day so any help would be highly appreciated
You can see how the breadcrumbs looks like in here:
https://www.bitcoinhoy.co/criptomonedas/ethereum/
I managed to find the relevant php file and here's the code:
enter code here
<!-- ** Breadcrumb ** -->
<?php
if( !empty( $global_breadcrumb ) ) {
if(empty($settings)) { $settings['enable-sub-title'] = true; }
if( isset( $settings['enable-sub-title'] ) && $settings['enable-sub-title'] ) {
$breadcrumbs = array();
$bstyle = digibit_cs_get_option( 'breadcrumb-style', 'default' );
$separator = '<span class="'.digibit_cs_get_option( 'breadcrumb-delimiter', 'fa default' ).'"></span>';
if( is_singular('post') ){
$cat = get_the_category();
$cat = $cat[0];
$breadcrumbs[] = get_category_parents( $cat, true, $separator );
}
$breadcrumbs[] = the_title( '<span class="current">', '</span>', false );
$bcsettings = isset( $settings['breadcrumb_background'] ) ? $settings['breadcrumb_background'] : array();
$style = digibit_breadcrumb_css( $bcsettings );
digibit_breadcrumb_output ( the_title( '<h1>', '</h1>',false ), $breadcrumbs, $bstyle, $style );
}
}
?><!-- ** Breadcrumb End ** -->
Any idea how can I modify the "home" text to something else?
It looks like Digibit is a premium theme. Modifying a theme file may not be a great idea because if they update the theme, it will break the modifications you make.
What you can do is add this in your CSS (perhaps in Customize > Additional CSS):
.breadcrumb a:first-child {
font-size: 0;
}
.breadcrumb a:first-child:after {
content: "Something Else";
font-size: 14px;
}
Related
I have a Wordpress problem that I can't fix....
Woocommerce is using a sidebar with product filters.
I'd simply like to hide the sidebar + filters on Woocommerce parent pages.
I first tried by adding a class which I could hide the sidebar content with css, like this :
add_filter( 'fusion_sidebar_1_class', 'usl_wc_product_cats_css_body_class' );
function usl_wc_product_cats_css_body_class( $classes )
{
if( is_tax( 'product_cat' ) ) {
$cat = get_queried_object();
if( 0 == $cat->parent ) $classes[] = 'usl-parent';
}
return $classes;
}
But this obviously leaves the main content at 80% or so.
So I'm now trying to remove the sidebar instead using a mix of the above and some example code from the Avada help pages. Code is below but totally doesn't work! Can anyone please help?
function remove_woo_commerce_sidebar() {
global $avada_woocommerce;
{
if( is_tax( 'product_cat' ) )
{
$cat = get_queried_object();
if( 0 == $cat->parent )
remove_action( 'woocommerce_sidebar', array( $avada_woocommerce, 'add_sidebar' ), 10 );
}
}
add_action( 'after_setup_theme', 'remove_woo_commerce_sidebar' );
Can't you just do this through CSS? Just change the selector to match the page type you want to affect
.woocommerce-page #content .single_wrap {
float: none;
width: 100%;
}
.woocommerce-page #sidebar {
display: none;
}
Couldn't find a neat way to unload the sidebar so added an extra body class so I could target both the main content & sidebar with this :
add_filter( 'body_class','usl_body_classes' );
function usl_body_classes( $classes )
{
if( is_tax( 'product_cat' ) ) {
$cat = get_queried_object();
if( 0 == $cat->parent ) $classes[] = 'usl_full_woo_css';
}
return $classes;
}
i got this code from researching and trying to modify it but no luck. I want the last item in yoast breamcrumbs not to appear on single pages only
if ( is_single() ) {
/*Remove Last item in Yoast SEO Breadcrumb */
function adjust_single_breadcrumb( $link_output) {
if(strpos( $link_output, 'breadcrumb_last' ) !== false ) {
$link_output = '';
}
return $link_output;
}
add_filter('wpseo_breadcrumb_single_link', 'adjust_single_breadcrumb' );
};
I tried adding if is single in between the function and also this
if(strpos( $link_output, 'breadcrumb_last' ) !== false && is_single) {
unfortunately, the whole breadcrumb disappears.
with this code, you can remove post title in single page.
add_filter('wpseo_breadcrumb_single_link_info', 'remove_post_title_wpseo_breadcrumb', 10, 3);
function remove_post_title_wpseo_breadcrumb($link_info, $index, $crumbs)
{
if (is_singular() && isset($link_info['id']))
return [];
return $link_info;
}
Updated: In the latest version above code does not work perfectly.
for this reason, I removed the last item with regex:
function getBreadcrumb() {
if ( function_exists( 'yoast_breadcrumb' ) ) {
ob_start();
yoast_breadcrumb( '<p id="breadcrumb" class="meta-info">', '</p>' );
$breadcrumb = trim( ob_get_clean() );
if ( is_singular() )
$breadcrumb = trim( preg_replace( '/ ' . WPSEO_Options::get( 'breadcrumbs-sep' ) . ' <span class="breadcrumb_last" aria-current="page">(.*)<\/span>/i', '',
$breadcrumb ) );
echo $breadcrumb;
}
}
And call the function anywhere you want:
<?php getBreadcrumb() ?>
I'm trying to figure a way to use the home icon from FontAwesome in my breadcrumb trail for WooCommerce but it just shows up as a blank. Basically, I tweaked the code Woo provides to replace breadcrumb text with other text, but I guess it doesn't like HTML tags. This is my code.
add_filter( 'woocommerce_breadcrumb_defaults', 'wcc_change_breadcrumb_home_text' );
function wcc_change_breadcrumb_home_text( $defaults ) {
$defaults['home'] = '<i class="fas fa-home"></i>';
return $defaults;
}
The filter only allows you to change the text without adding HTML tags as the home delimiter is wrapped in esc_html(). Here's one solution. Change the filter to the following:
add_filter( 'woocommerce_breadcrumb_defaults', 'wcc_change_breadcrumb_home_text' );
function wcc_change_breadcrumb_home_text( $defaults ) {
$defaults['before'] = '<span class="nmr-crumb">';
$defaults['after'] = '</span>';
$defaults['home'] = ' ';
return $defaults;
}
Use a space inside the single quotes on the line with $defaults['home'] = ' ';
Next, you'll need to add the following to your theme style.css:
.woocommerce-breadcrumb .nmr-crumb:first-child a {
text-decoration: none;
}
.woocommerce-breadcrumb .nmr-crumb:first-child a::before {
font-family: FontAwesome;
content: '\f015';
}
Credit: https://wordpress.org/support/topic/swap-home-for-icon/
A less elegant solution would be to edit the breadcrumbs template file. You'll need to use a child theme and have an existing breadcrumbs template file under:
/woocommerce/global/breadcrumb.php
where / is your child theme folder. Inside breadcrumb.php find the following if statement:
if ( ! empty( $crumb[1] ) && sizeof( $breadcrumb ) !== $key + 1 ) {
echo '' . esc_html( $crumb[0] ) . '';
} else {
echo esc_html( $crumb[0] );
}
change the above if statement to the following:
if ( ! empty( $crumb[1] ) && sizeof( $breadcrumb ) !== $key + 1 ) {
if (0==$key){
echo '<i class="fas fa-home"></i>';
}else{
echo '' . esc_html( $crumb[0] ) . '';
}
}else{
echo esc_html($crumb[0]);
}
Here's a guide on how to edit WooCommerce template files.
I have a category called 'News'. The category ID is '20'. I am using the Divi (Divi child) theme + Wordpress and want to shorten the excerpt for the News category.
I typically would use the 'add_filter' function like this:
<pre>
add_filter('excerpt_length', 'news_excerpt_length');
function news_excerpt_length($length) {
if(in_category(20)) {
return 30;
} else {
return 60;
}
}
</pre>
But that ain't workin'. I found the excerpt control in the 'main-modules.php' and figure to add my filter here? Has anyone done this?
I added the 'main-module.php' to the root of my child theme and then added this to my child 'functions.php'
<pre>
if ( ! function_exists( 'et_builder_add_main_elements' ) ) :
function et_builder_add_main_elements() {
require ET_BUILDER_DIR . 'main-structure-elements.php';
require 'main-modules.php';
do_action( 'et_builder_ready' );
}
endif;
</pre>
It didn't break the theme, but it didn't work either. Does anyone have any experience with this particular issue?
-Thanks!
To override the post_excerpt lengh, you can find in custom_functions.php the function truncate_post()
if ( ! function_exists( 'truncate_post' ) ) {
function truncate_post( $amount, $echo = true, $post = '', $strip_shortcodes = false ) {
global $shortname;
if ( '' == $post ) global $post;
$post_excerpt = '';
$post_excerpt = apply_filters( 'the_excerpt', $post->post_excerpt );
if ( 'on' == et_get_option( $shortname . '_use_excerpt' ) && '' != $post_excerpt ) {
if ( $echo ) echo $post_excerpt;
else return $post_excerpt;
} else {
// get the post content
$truncate = $post->post_content;
// remove caption shortcode from the post content
$truncate = preg_replace( '#\[caption[^\]]*?\].*?\[\/caption]#si', '', $truncate );
// remove post nav shortcode from the post content
$truncate = preg_replace( '#\[et_pb_post_nav[^\]]*?\].*?\[\/et_pb_post_nav]#si', '', $truncate );
// Remove audio shortcode from post content to prevent unwanted audio file on the excerpt
// due to unparsed audio shortcode
$truncate = preg_replace( '#\[audio[^\]]*?\].*?\[\/audio]#si', '', $truncate );
if ( $strip_shortcodes ) {
$truncate = et_strip_shortcodes( $truncate );
} else {
// apply content filters
$truncate = apply_filters( 'the_content', $truncate );
}
// decide if we need to append dots at the end of the string
if ( strlen( $truncate ) <= $amount ) {
$echo_out = '';
} else {
$echo_out = '...';
// $amount = $amount - 3;
}
// trim text to a certain number of characters, also remove spaces from the end of a string ( space counts as a character )
$truncate = rtrim( et_wp_trim_words( $truncate, $amount, '' ) );
// remove the last word to make sure we display all words correctly
if ( '' != $echo_out ) {
$new_words_array = (array) explode( ' ', $truncate );
array_pop( $new_words_array );
$truncate = implode( ' ', $new_words_array );
// append dots to the end of the string
$truncate .= $echo_out;
}
if ( $echo ) echo $truncate;
else return $truncate;
};
}
}
You don't need to put if ( ! function_exists( 'truncate_post' ) ) { to make it work just create your function with the same name in functions.php
If you are using a child theme (I really hope so with a theme like this), copy/paste index.php and paste these lines, line 54
if(in_category(20)) {
truncate_post( 30 );
} else {
truncate_post( 60 );
}
It can be easier
Hope it helps
I ended up doing it ( although I don't know which solution is better ) by putting this in my 'main-module.php' starting on line 12319
// do not display the content if it contains Blog, Post Slider, Fullwidth Post Slider, or Portfolio modules to avoid infinite loops
if ( ! has_shortcode( $post_content, 'et_pb_blog' ) && ! has_shortcode( $post_content, 'et_pb_portfolio' ) && ! has_shortcode( $post_content, 'et_pb_post_slider' ) && ! has_shortcode( $post_content, 'et_pb_fullwidth_post_slider' ) ) {
if ( 'on' === $show_content ) {
global $more;
// page builder doesn't support more tag, so display the_content() in case of post made with page builder
if ( et_pb_is_pagebuilder_used( get_the_ID() ) ) {
$more = 1;
the_content();
} else {
$more = null;
the_content( esc_html__( 'read more...', 'et_builder' ) );
}
} else {
if ( has_excerpt() ) {
the_excerpt();
} else {
if(in_category(20)) {
echo wpautop( truncate_post( 70, false ) );
} else {
echo wpautop( truncate_post( 370, false ) );
}
}
}
} else if ( has_excerpt() ) {
the_excerpt();
}
I'm using child theme of default theme in WP and I have changed background image (in wp-admin)... it's generated with wp_head(); function in header.php... output source code looks like this:
<style type="text/css" id="custom-background-css">
body.custom-background { background-color: #fffffe; background-image: url('http://example.com/wp-content/uploads/header.jpg'); background-repeat: no-repeat; background-position: top center; background-attachment: fixed; }
</style>
I need to modify url of the image (some hook, functions.php modification or anything else) for some reason but I am not able to find how to do this. I've searched all theme files with no resault :(
anyone know, how to do it (of course, without modifying wp core files - just theme modification or plugin)
To be honest, I'm not a fan of WordPress adding unadjustable functionality to any theme. This is how I solved it. I removed the custom-background class from the body tag. Hopefully it's still useful to someone.
function disable_custom_background_css($classes)
{
$key = array_search('custom-background', $classes, true);
if($key !== false)
unset($classes[$key]);
return $classes;
}
And before calling body_class(), preferably in functions.php
add_filter('body_class', 'disable_custom_background_css');
This prevents the script in wp_head from adding this particular style to the body tag. Now you can decide how to implement a background image.
The code in the WP tuts article didn't work for me, but I managed to make some modifications to get it working.
global $wp_version;
if ( ! function_exists( 'change_custom_background_cb' ) ) :
function change_custom_background_cb() {
$background = get_background_image();
$color = get_background_color();
if ( ! $background && ! $color )
return;
$style = $color ? "background-color: #$color;" : '';
if ( $background ) {
$image = " background-image: url('$background');";
$repeat = get_theme_mod( 'background_repeat', 'repeat' );
if ( ! in_array( $repeat, array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) )
$repeat = 'repeat';
$repeat = " background-repeat: $repeat;";
$position = get_theme_mod( 'background_position_x', 'left' );
if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) )
$position = 'left';
$position = " background-position: top $position;";
$attachment = get_theme_mod( 'background_attachment', 'scroll' );
if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) )
$attachment = 'scroll';
$attachment = " background-attachment: $attachment;";
$style .= $image . $repeat . $position . $attachment;
}
?>
<style type="text/css" id="custom-background-css">
.custom-background { <?php echo trim( $style ); ?> }
</style>
<?php
}
if ( version_compare( $wp_version, '3.4', '>=' ) ) {
add_theme_support( 'custom-background', array( 'wp-head-callback' => 'change_custom_background_cb','default-color' => 'fff' ) );
}
else {
add_custom_background('change_custom_background_cb');
}
endif;
Here's eexactly what I have been looking for: http://wp.tutsplus.com/articles/tips-articles/modifying-custom-background-feature-for-any-html-element-you-want/