Thumbnail size, blog title and number of entries shown

Hello!
I’ve got three questions:

  1. I’ve changed the title of my blog page from default to ‘Blog diy decoración’ but it’s showing just ‘Blog’. I’ve changed the title and also written the new title on the alternate index title field but the site just shows ‘Blog’ instead of ‘Blog diy decoración’. What can I do to solve this?

  2. I’d like my blog page to show just 5 entries per page but I want my category pages to show 10 entries. How can I achieve this?

  3. I’ve added this code to my child theme’s function.php file so the recent posts show the excerpt.

 // Additional Functions
// =============================================================================

// Add Excerpts to the recent post element
// =============================================================================
function x_shortcode_recent_posts_v2code( $atts ) {
  extract( shortcode_atts( array(
    'id'           => '',
    'class'        => '',
    'style'        => '',
    'type'         => 'post',
    'count'        => '',
    'category'     => '',
    'offset'       => '',
    'orientation'  => '',
    'show_excerpt' => 'false',
    'no_sticky'    => '',
    'no_image'     => '',
    'img_size'     => '',
    'fade'         => ''
  ), $atts, 'x_recent_posts' ) );

  $allowed_post_types = apply_filters( 'cs_recent_posts_post_types', array( 'post' => 'post' ) );
  $type = ( isset( $allowed_post_types[$type] ) ) ? $allowed_post_types[$type] : 'post';

  $id            = ( $id           != ''     ) ? 'id="' . esc_attr( $id ) . '"' : '';
  $class         = ( $class        != ''     ) ? 'x-recent-posts cf ' . esc_attr( $class ) : 'x-recent-posts cf';
  $style         = ( $style        != ''     ) ? 'style="' . $style . '"' : '';
  $count         = ( $count        != ''     ) ? $count : 3;
  $category      = ( $category     != ''     ) ? $category : '';
  $category_type = ( $type         == 'post' ) ? 'category_name' : 'portfolio-category';
  $offset        = ( $offset       != ''     ) ? $offset : 0;
  $orientation   = ( $orientation  != ''     ) ? ' ' . $orientation : ' horizontal';
  $show_excerpt  = ( $show_excerpt == 'true' );
  $no_sticky     = ( $no_sticky    == 'true' );
  $no_image      = ( $no_image     == 'true' ) ? $no_image : '';
  $img_size      = ( $img_size     != '' ) ? $img_size : 'entry-cropped';
  $fade          = ( $fade         == 'true' ) ? $fade : 'false';

  $js_params = array(
    'fade' => ( $fade == 'true' )
  );

  $data = cs_generate_data_attributes( 'recent_posts', $js_params );

  $output = "<div {$id} class=\"{$class}{$orientation}\" {$style} {$data} data-fade=\"{$fade}\" >";

    $q = new WP_Query( array(
  'orderby'             => 'date',
  'post_type'           => "{$type}",
  'posts_per_page'      => "{$count}",
  'offset'              => "{$offset}",
  "{$category_type}"    => "{$category}",
  'ignore_sticky_posts' => $no_sticky
) );

if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post();

  if ( $no_image == 'true' ) {
    $image_output       = '';
    $image_output_class = 'no-image';
  } else {
    $image              = wp_get_attachment_image_src( get_post_thumbnail_id(), $img_size );
    $bg_image           = ( $image[0] != '' ) ? ' style="background-image: url(' . $image[0] . ');"' : '';
    $image_output       = '<div class="x-recent-posts-img"' . $bg_image . '></div>';
    $image_output_class = 'with-image';
  }

   $excerpt = ( $show_excerpt ) ? '<div class="x-recent-posts-excerpt"><p style="color:initial;">' . preg_replace('/<a.*?more-link.*?<\/a>/', '', cs_get_raw_excerpt() ) . '</p></div>' : '';

  $output .= '<a class="x-recent-post' . $count . ' ' . $image_output_class . '" href="' . get_permalink( get_the_ID() ) . '" title="' . esc_attr( sprintf( __( 'Permalink to: "%s"', 'cornerstone' ), the_title_attribute( 'echo=0' ) ) ) . '">'
             . '<article id="post-' . get_the_ID() . '" class="' . implode( ' ', get_post_class() ) . '">'
               . '<div class="entry-wrap">'
                 . $image_output
                 . '<div class="x-recent-posts-content">'
                   . '<h3 class="h-recent-posts">' . get_the_title() . '</h3>'
                   . '<span class="x-recent-posts-date">' . get_the_date() . '</span>'
                    . $excerpt
                 . '</div>'
               . '</div>'
             . '</article>'
           . '</a>';

endwhile; endif; wp_reset_postdata();
  $output .= '</div>';

  return $output;
}

// =============================================================================

The thumbnails are cropped horizontally and i’d like to change that because my feature images are all vertical. How can I change it?

That is all. Thank you so much

Hi there,

Thanks for writing in.

  1. What stack you’re on, the blog title option is usually configurable within X > Launch > Theme Options > {Selected Stack} > Blog Options. Assigning a page as blog posts page will only use the same URL, but not the title and other options you set within the page.

  2. It’s only possible with customization and I’m not sure if it’s going to work, but please try adding this code to your child theme’s functions.php

function change_wp_search_size( $qv ) {
      if ( is_home() ) {
                $qv['posts_per_page'] = 5; 
       } else if ( is_category() ) {
                $qv['posts_per_page'] = 10; 
       }
	return $qv;
}
add_filter('request', 'set_page_per_posts'); 
add_filter( 'query_vars', 'set_page_per_posts' );

Again, this may not work.

  1. That code is for old shortcode and it’s not applicable for the new cornerstone’s recent posts shortcode. I recommend using Essential Grid plugin on this one if you wish to customize every aspect of the element.

Hope this help.

Hi there! I’ve been using X Theme since it came out so I guess I’m a bit old fashioned :slight_smile:

First thing solved, thank you.

Second issue, tried the code, didn’t work but I can live without it. Thank you!

Third issue. I’m not using cornerstone. I installed the plugin you recommended but I don’t if I can use it outside cornerstone? This is what I have now and it looks exactly as i want except for the images. It’s part of my homepage but it’s not the only thing in there, so if I try to edit it with cornerstone I’ll lose everything I’ve been working on.

Hi there,

You can still use the Essential Grid plugin outside of cornerstone.

You will have to use its shortcode on the page where you want it to be displayed.

Hope this helps.

Hi Jade, thank you for your answer
I’ve tried the plugin, but I’ve noticed that it taked way longer to load. I need to include three different sets of recent posts on my homepage and I can’t afford it to be that slow.

The problem is just that the images are cropped because it’s using a smaller version of the image instead of the original one. http://www.drlivinghome.com/wp-content/uploads/2017/09/diy-cojin-suelo-boho-1-5-800x473.jpg

If I manually get rid of the -800x473.jpg I can see the image fine, is there a way using code to stop the recent posts shortcode from using the cropped version of the images?

Thank you for your help

Hey There,

To resolve the image size in the recent post element, please remove this line:

$img_size      = ( $img_size     != '' ) ? $img_size : 'entry-cropped';

And replace it with this line:

$img_size      = ( $img_size     != '' ) ? $img_size : 'full';

This line will display the full image.

That did the trick. Thank you so much, have a lovely a day :slight_smile:

Glad to hear we managed to help!

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