Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #909305

    jkneitel
    Participant

    Also, this solution involving category pages (instead of actual pages) also means that the title remains the same for all category pages (the default is “Category Archive”). Much preferred would be to have a customizable title. Seemingly, the easiest way to do this would be to customize an individual page.

    Is there no way to introduce posts from a particular category on a particular page?

    #909331

    jkneitel
    Participant

    And to clarify my immediately previous post, is there now way to introduce posts from a particular category on a particular page without create a menu item with only posts from that category? That is, can this be done by creating an actual “page” on the menu instead of a “category” on the menu.

    #909810

    Friech
    Moderator

    Hi There,

    That default Category Archive title is a fallback, meaning if you have not assign a Archive Title for a specific category, then that fallback would be triggered.

    You can set the categories Archive Title by navigating to Posts > Categories then edit a category and enter a value for its Archive Title field.

    Hope it helps, Cheers!

    #909945

    jkneitel
    Participant

    That only partially answers my requests.

    Please help me put the following content on an actual menu page (not a “category” page): static content at the top (e.g., introductory text; and not just a title) followed by posts from a particular category.

    Surely there must be a way to do this?

    #910240

    Rupok
    Member

    Hi there,

    Thanks for updating. You have posted several replies which is confusing. Could you summarize your remain issue in a single reply that what you need to achieve right now?

    Cheers!

    #910593

    jkneitel
    Participant

    On a page, I would like my pages to be set up visually like the following:

    Header and menu items
    =========================

    Static content (e.g., text and images)

    =========================

    Dynamic content (e.g., posts from a single category)

    [Note: I would really prefer to not use set up a page using the select category feature under the menu setup. When I do this, I lose a lot of customization (including being able to introduce static content, a slider, etc., and I can’t edit category pages using Cornerstone)

    #911699

    Lely
    Moderator

    Hello There,

    Thank you for the clarification.
    Why not use RECENT POST element to display dynamic content like post? Recent post element can be filtered by CATEGORY. It is available in Cornerstone. Using it in Cornerstone means that you have absolute control on which category to display and the position where you want it to show.

    Hope this helps.

    #911799

    jkneitel
    Participant

    I appreciate that proposed solution.

    However, it really isn’t working. I tried the recent posts but they are not showing the way that one would expect. Inside my posts is text and images. Unfortunately, when using the recent posts, only a featured image is displayable (and I’m not using featured images) along with only the title of the post and the date of the post.

    The actual post itself does not display, nor does the meta data appear the same as it does on regular blog posts.

    If you can figure how to make recent posts work, I’ll be all over them. Please let me know what can be done.

    #912266

    Lely
    Moderator

    Hello There,

    Please add this on your child theme’s functions.php file:

    // Recent Posts Customize
    // =============================================================================
    
    function x_shortcode_recent_posts_with_excerpt( $atts ) {
      extract( shortcode_atts( array(
        'id'           => '',
        'class'        => '',
        'style'        => '',
        'type'         => 'post',
        'count'        => '',
        'category'     => '',
        'offset'       => '',
        'orientation'  => '',
        'show_excerpt' => 'true',
        'no_sticky'    => '',
        'no_image'     => '',
        '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 : '';
      $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(), 'entry-cropped' );
            $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>' . preg_replace('/<a.*?more-link.*?<\/a>/', '', cs_get_raw_excerpt() ) . '</p></div>' : '';
    
        //
        // Author.
        //
    
        $author = sprintf( ' %1$s %2$s</span>',
          __( 'by', '__x__' ),
          get_the_author()
        );
    
        //
        // Date.
        //
    
        $date = sprintf( '<span class="x-recent-posts-content"><time class="entry-date" datetime="%1$s">%2$s</time></span>',
          esc_attr( get_the_date( 'c' ) ),
          esc_html( get_the_date() )
        );
    
        //
        // Categories.
        //
    
        if ( get_post_type() == 'x-portfolio' ) {
          if ( has_term( '', 'portfolio-category', NULL ) ) {
            $categories        = get_the_terms( get_the_ID(), 'portfolio-category' );
            $separator         = ', ';
            $categories_output = '';
            foreach ( $categories as $category ) {
              $categories_output .= '<a href="'
                                  . get_term_link( $category->slug, 'portfolio-category' )
                                  . '" title="'
                                  . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                                  . '"> '
                                  . $category->name
                                  . '</a>'
                                  . $separator;
            }
    
            $categories_list = sprintf( '<span class="x-recent-posts-content">%1$s %2$s',
              __( 'In', '__x__' ),
              trim( $categories_output, $separator )
            );
          } else {
            $categories_list = '';
          }
        } else {
          $categories        = get_the_category();
          $separator         = ', ';
          $categories_output = '';
          foreach ( $categories as $category ) {
            $categories_output .= '<a  class="meta-cat-link" href="'
                                . get_category_link( $category->term_id )
                                . '" title="'
                                . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                                . '"> '
                                . $category->name
                                . '</a> '
                                . $separator;
          }
    
          $categories_list = sprintf( '<span class="x-recent-posts-content">%1$s %2$s',
            __( 'In', '__x__' ),
            trim( $categories_output, $separator )
          );
        }
    
          $output .= '<div class="x-recent-post' . $count . ' ' . $image_output_class . '" >'
                     . '<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>'
                            .$categories_list
    						.$date
    						." ".$author
          				   . $excerpt
    					   .'<a href="' . get_permalink( get_the_ID() ) . '" class="read-more-custom" title="' . esc_attr( sprintf( __( 'Permalink to: "%s"', 'cornerstone' ), the_title_attribute( 'echo=0' ) ) ) . '">Read more</a>'
                         . '</div>'
                       . '</div>'
                     . '</article>'
                   . '</div>';
    
        endwhile; endif; wp_reset_postdata();
    
      $output .= '</div>';
    
      return $output;
    }
    
    add_action('wp_head', 'update_x_recent_posts_to_v2');
    
    function update_x_recent_posts_to_v2() {
      remove_shortcode( 'x_shortcode_recent_posts' );
      add_shortcode( 'x_recent_posts', 'x_shortcode_recent_posts_with_excerpt' );
    }
    

    Then please also add this CSS:

    .x-recent-posts a.meta-cat-link {
        border: none;
        box-shadow: none;
        display: initial;
        padding: 0 5px 0 0;
        margin: 0 !important;
        float: none;
    }

    Then you can use recent post shortcode: [x_recent_posts count="2"]
    Further customizations from here would be getting into custom development, which is outside the scope of support we can offer. If you need more in depth changes, you may wish to consult with a developer. X is quite extensible with child themes, so there are plenty of possibilities. Thanks for understanding.

    #912285

    jkneitel
    Participant

    Thanks for this!

    Not working yet. I previously included the following code in my _content.php file. Would this be interfering somehow?

    <?php

    if ( is_singular() || $is_full_post_content_blog ) :
    x_get_view( ‘global’, ‘_content’, ‘the-content’ );
    if ( $stack == ‘renew’ ) :
    x_get_view( ‘renew’, ‘_content’, ‘post-footer’ );
    endif;
    else :
    x_get_view( ‘global’, ‘_content’, ‘the-excerpt’ );
    endif;

    ?>

    #912634

    Lely
    Moderator

    Hello There,

    The code you have posted is the default code for _content.php file. There should be no conflict between that and recent post shortcode suggested on the previous reply. Adding the shortcode on any page should achieve that.
    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    #913797

    jkneitel
    Participant
    This reply has been marked as private.
    #914101

    Lely
    Moderator

    Hello There,

    I can’t login using the credentials. See attached screenshot. But then when I visit this page:http://3bd.249.myftpupload.com/firewalker-body/ the recent post shortcode is working as intended.
    It is showing the post image which you can set to OFF using this parameter:no_image. Then the custom code added the meta information and the excerpt with readmore link to the full content. We can also filter it by the default category filter for recent post shortcode. Unfortunately, that’s the extent of customization we can give based on your reply above:Dynamic content (e.g., posts from a single category). If you want to achieve more than this you may wish to consult a web developer. Thank you for understanding.

    #982598

    jkneitel
    Participant

    Thank you,

    When I try the code, only a featured image is displayable. I would prefer not to use a featured image as I’m using images (sometimes more than one) that are inserted into the content of the blog posts. The recent posts code does not display any of the images. The only way to get an image to display is if I’m using a featured image (which I prefer not to do).

    Is there any way for the recent posts shortcode to have the posts appear exactly as the blog posts do (with the same formatting for the meta information; and with an option for “read more” or no “read more”)?

    Thanks again!

    #983439

    Lely
    Moderator

    Hi There,

    We can set no_image property to true if you don’t want featured image to display as stated on the previous reply. Unfortunately, recent posts is not originally built to display the whole post content. It is possible via custom development but that would be beyond the scope of the support we can give. It would entail more structural and custom CSS change. It is also a wordpress default that archive pages only display excerpts of the post and not the entire post content. You may wish to consult a web developer to achieve this. Thank you for understanding.

    Always,
    X