Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1401975
    victorlisboa
    Participant

    hi, first of all, congrats for this awesome theme. But there’s a way to carousel dynamically exclude the actual post? since the user is viewing a post, there’s no reason for carousel include it. thank you in advance.

    #1402049
    Darshana
    Moderator

    Hi there,

    Thanks for writing in! To assist you with this request, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

    #1402110
    victorlisboa
    Participant

    Sure, for example I would like to exclude from carousel the entry for this post when the user is reading it: http://ano-zero.com/o-nosso-real-despertar/

    #1402694
    Rue Nel
    Moderator

    Hello There,

    Thanks for updating in! To resolve this issue, since you have your child theme active and ready, please follow the following steps below:
    1] Using Notepad or TextEdit or Sublime Text or any text editor, please create a new file in your local machine.
    2] Insert the following code into that new file

    <?php
    
    // =============================================================================
    // VIEWS/ETHOS/_POST-CAROUSEL.PHP
    // -----------------------------------------------------------------------------
    // Outputs the post carousel that appears at the top of the masthead.
    // =============================================================================
    
    GLOBAL $post_carousel_entry_id;
    
    $post_carousel_entry_id = get_the_ID();
    
    $is_enabled = x_get_option( 'x_ethos_post_carousel_enable' ) == '1';
    $count      = x_get_option( 'x_ethos_post_carousel_count' );
    $display    = x_get_option( 'x_ethos_post_carousel_display' );
    
    switch ( $display ) {
      case 'most-commented' :
        $args = array(
          'post_type'      => 'post',
          'posts_per_page' => $count,
          'orderby'        => 'comment_count',
          'order'          => 'DESC',
          'post__not_in'   => array($post_carousel_entry_id)
        );
        break;
      case 'random' :
        $args = array(
          'post_type'      => 'post',
          'posts_per_page' => $count,
          'orderby'        => 'rand',
          'post__not_in'   => array($post_carousel_entry_id)
        );
        break;
      case 'featured' :
        $args = array(
          'post_type'      => 'post',
          'posts_per_page' => $count,
          'orderby'        => 'date',
          'meta_key'       => '_x_ethos_post_carousel_display',
          'meta_value'     => 'on',
          'post__not_in'   => array($post_carousel_entry_id)
        );
        break;
    }
    
    ?>
    
    <?php if ( $is_enabled ) : ?>
    
      <ul class="x-post-carousel unstyled">
    
        <?php $wp_query = new WP_Query( $args ); ?>
    
        <?php if ( $wp_query->have_posts() ) : ?>
          <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
    
            <li class="x-post-carousel-item">
              <?php x_ethos_entry_cover( 'post-carousel' ); ?>
            </li>
    
          <?php endwhile; ?>
        <?php endif; ?>
    
        <?php wp_reset_query(); ?>
    
        <script>
    
        jQuery(document).ready(function() {
          jQuery('.x-post-carousel').slick({
            speed          : 500,
            slide          : 'li',
            slidesToShow   : <?php echo x_get_option( 'x_ethos_post_carousel_display_count_extra_large' ); ?>,
            slidesToScroll : 1,
            rtl            : <?php echo json_encode( is_rtl() ); ?>,
            responsive     : [
              { breakpoint : 1500, settings : { speed : 500, slide : 'li', slidesToShow : <?php echo x_get_option( 'x_ethos_post_carousel_display_count_large' ); ?> } },
              { breakpoint : 1200, settings : { speed : 500, slide : 'li', slidesToShow : <?php echo x_get_option( 'x_ethos_post_carousel_display_count_medium' ); ?> } },
              { breakpoint : 979,  settings : { speed : 500, slide : 'li', slidesToShow : <?php echo x_get_option( 'x_ethos_post_carousel_display_count_small' ); ?> } },
              { breakpoint : 550,  settings : { speed : 500, slide : 'li', slidesToShow : <?php echo x_get_option( 'x_ethos_post_carousel_display_count_extra_small' ); ?> } }
            ]
          });
        });
    
        </script>
    
      </ul>
    
    <?php endif; ?>

    3] Save the file named as _post-carousel.php
    4] Upload this file to your server in the child theme’s folder
    wp-content/themes/x-child/framework/views/ethos/

    We would loved to know if this has work for you. Thank you.

    #1403131
    victorlisboa
    Participant

    Well, it didn’t work. But since I’ve already have a _post-carousel.php in my child theme (due to exclude carousel in home) and to show recent posts, I realized that I can just insert “$exclude_ids = array(get_the_ID());” to exclude the actual post.

    So, for other clients too, heres de code we need to insert in _post-carousel.php (child theme) to hide carousel in home (appearing in posts and pages), showing recent posts AND excluding the actual post:

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

    <?php

    // =============================================================================
    // VIEWS/ETHOS/_POST-CAROUSEL.PHP
    // —————————————————————————–
    // Outputs the post carousel that appears at the top of the masthead.
    // =============================================================================

    GLOBAL $post_carousel_entry_id;

    $post_carousel_entry_id = get_the_ID();

    $is_enabled = x_get_option( ‘x_ethos_post_carousel_enable’ ) == ‘1’;
    $count = x_get_option( ‘x_ethos_post_carousel_count’ );
    $display = x_get_option( ‘x_ethos_post_carousel_display’ );

    $exclude_ids = array(get_the_ID()); // Enter the IDs of posts you want to exclude
    $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => $count, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post__not_in’ => $exclude_ids );

    ?>

    <?php if ( $is_enabled && (is_home() || is_front_page() ) ) { ?>

    <div class=”x-img-banner”>
    </div>

    <?php } else { ?>

    <ul class=”x-post-carousel unstyled”>

    <?php $wp_query = new WP_Query( $args ); ?>

    <?php if ( $wp_query->have_posts() ) : ?>
    <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>

    <li class=”x-post-carousel-item”>
    <?php x_ethos_entry_cover( ‘post-carousel’ ); ?>

    <?php endwhile; ?>
    <?php endif; ?>

    <?php wp_reset_query(); ?>

    <script>

    jQuery(document).ready(function() {
    jQuery(‘.x-post-carousel’).slick({
    speed : 500,
    slide : ‘li’,
    slidesToShow : <?php echo x_get_option( ‘x_ethos_post_carousel_display_count_extra_large’, ‘5’ ); ?>,
    slidesToScroll : 1,
    responsive : [
    { breakpoint : 1500, settings : { speed : 500, slide : ‘li’, slidesToShow : <?php echo x_get_option( ‘x_ethos_post_carousel_display_count_large’, ‘4’ ); ?> } },
    { breakpoint : 1200, settings : { speed : 500, slide : ‘li’, slidesToShow : <?php echo x_get_option( ‘x_ethos_post_carousel_display_count_medium’, ‘3’ ); ?> } },
    { breakpoint : 979, settings : { speed : 500, slide : ‘li’, slidesToShow : <?php echo x_get_option( ‘x_ethos_post_carousel_display_count_small’, ‘2’ ); ?> } },
    { breakpoint : 550, settings : { speed : 500, slide : ‘li’, slidesToShow : <?php echo x_get_option( ‘x_ethos_post_carousel_display_count_extra_small’, ‘1’ ); ?> } }
    ]
    });
    });

    </script>

    <?php } ?>

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

    Thank you very much for your assistance!

    #1403203
    Thai
    Moderator

    Hi There,

    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 login 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.

    Thanks.

    #1403327
    victorlisboa
    Participant
    This reply has been marked as private.
    #1403563
    Rue Nel
    Moderator

    Hello There,

    Thanks for providing the information. Regretfully the given ftp details is not working for us. Please double check it so that we can log in and check your _psot-carousel.php file

    By the way, I checked the page (http://ano-zero.com/espirito-santo/) again and I no longer see any duplicates of the post in the carousel.

    http://prntscr.com/eiwucc

    Hope to hear from you soon.

    #1403920
    victorlisboa
    Participant
    This reply has been marked as private.
    #1404271
    Rue Nel
    Moderator

    Hello There,

    You’re most welcome. Glad to know that it has been useful to you.
    If you need anything else we can help you with, don’t hesitate to open another thread.

    Cheers.

  • <script> jQuery(function($){ $("#no-reply-1401975 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>