Header on blogpages

Hi there,

I use X with renew stack

I have two questions:

  1. For my blogpage I use a LayerSlider above masthead (page template is no container, header/footer). But my blogitems are shown without a header.

Is there something I can do about that?

  1. I want to translate the Read More link. So I installed a child theme to edit functions.php with code I found on this forum. After doing that, page templates were not availalble anymore and some pages had a wrong page template. I found out that more people had this problem. Maybe the code I used was not ok. So my question: what code should I use to translate the Read More text?

Thank you so much for your help.
Regards Marjolijn

Hello @MarjolijnZegers,

Thanks for asking. :slight_smile:

  1. The reason slider is not showing up in single blog posts in because slider is assigned to the blog index page.

  2. Please try adding following code in child theme function.php file to translate read more text:

    function x_excerpt_string( $more ) {

    $stack = x_get_stack();

    if ( $stack == ‘integrity’ ) {
    return ’ …

    ’;
    } else if ( $stack == ‘renew’ ) {
    return ’ … ’ . __( ‘Read More’, ‘x’ ) . ‘’;
    } else if ( $stack == ‘icon’ ) {
    return ’ …’;
    } else if ( $stack == ‘ethos’ ) {
    return ’ …’;
    }

    }

Thanks.

Hi @Prasant,

Thanks for your answers. For question 1: I understand that the sllider is assigned to the blog index page. I thought that blog item pages inherited the settings of the index page. I understand now that this is not the case. But how can I assign a header to the blog item pages?

  1. I tried your code. And the read more text has dissapeared. Now […] is shown instead of Lees verder. Another problem also has returned. By activitating the child theme, all the page templates have dissapeared. I will give you my credentials so you can have a look into the dashboard.

I hope you can find the solution.

Regards, Marjolijn

Hi,

I would like to check but it looks like your site is down at the moment.

Kindly check and let us know.

Thanks

Hi @Paul,

Can you please try again? I just checked, the site can be reached.
I just noticed that the page templates have returned. So that problem is solved.

Regards, Marjolijn

Hi There,

To assign a header image to single blog posts, try adding the following Javascript code into your Theme Options > Global Javascript section.

$(function() {
jQuery('.single-post .x-landmark').prepend('<img id="myImg" src="path.to/image.jpg" />');
});

Hope that helps.

Hi @mldarshana

Unfortunately… I can see it in the preview

But not on the frontside. And the image is shown underneath the navigation and not fullwidth…

Regards, Marjolijn

Hi Marjolijn,

I am going to give a different approach, but since this is a customization please understand that it would ultimately be your responsibility to take it from here.

Since this will require the child theme’s functions.php file. Please setup a child theme and don’t forget to activate it.

How To Setup Child Themes

Then add the following code to your child theme’s functions.php file (via FTP).

/**
Add a custom slider on top of the single posts page
*/
function custom_slider() { 
 if ( is_single () ) : ?>
  <div class="custom-slider">
    <?php echo do_shortcode( 'YOUR SLIDER SHORTCODE HERE' ); ?>
  </div>
  <?php endif; 
}
add_action('x_after_site_begin','custom_slider', 30);

Replace the YOUR SLIDER SHORTCODE HERE phrase on the code with your actual slider shortcode.

Remember to clear all caches (plugin, server-side, CDN, and browser’s cache) before previewing the pages so that the code from the updated files is always in use.

Cheers!

Thanks a lot!!

I am very happy with this solution. It works fine.

Also thanks for your secure note.

Then one question left: How can I translate the Read More in the blog posts. You gave me the following code:

function x_excerpt_string( $more ) {
    
$stack = x_get_stack();

  if ( $stack == 'integrity' ) {
    return ' ... <div><a href="' . get_permalink() . '" class="more-link">' . __( 'Read More', '__x__' ) . '</a></div>';
  } else if ( $stack == 'renew' ) {
    return ' ... <a href="' . get_permalink() . '" class="more-link">' . __( 'Read More', '__x__' ) . '</a>';
  } else if ( $stack == 'icon' ) {
    return ' ...';
  } else if ( $stack == 'ethos' ) {
    return ' ...';
  }
  
}

Which I added to functions.php. I don’t know where to fill in Lees verder. I tried different things but it did not work. What is the solution?
Thanks a lot.

Regards Marjolijn

Hello @MarjolijnZegers,

Please replace Read More text in above code with Lees verder. Let us know how it goes.

Thanks.

Hi @Prasant,

I tried but it doesn’t work. The code in functions.php is now:

function x_excerpt_string( $more ) {

$stack = x_get_stack();

if ( $stack == ‘integrity’ ) {
return ’ …

’ . __( ‘Lees verder’, ‘x’ ) . ‘
’;
} else if ( $stack == ‘renew’ ) {
return ’ … ’ . __( ‘Lees verder’, ‘x’ ) . ‘’;
} else if ( $stack == ‘icon’ ) {
return ’ …’;
} else if ( $stack == ‘ethos’ ) {
return ’ …’;
}
}

Also: there is no link anymore.

Regards Marjolijn

Hi Marjolijn,

Still, we can’t view your site. So I can’t see what is happening. Try adding this code to your child theme’s functions.php file instead.

add_filter('gettext', 'translate_text' );
function translate_text($translated) { 
  $translated = str_ireplace('Read More', 'Lees verder', $translated);
  return $translated; 
}

Thanks,

Thanks a lot. This is working!! Strange that you have problems with viewing the site. I don’t have these problems. Should this be a hosting thing or do you think it could there be something wrong in the installation?

Regards Marjolijn

Hi there,

I think it was a glitch regarding the hosting service provider as I could access your website with no problem. Anyway it is working now :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.