• 27-04-2020, 11:51:19
    #1
    Selamlar.

    Aşağıdaki kod parçacığı bulunduğu sayfada tüm yazarları listeleniyor. Bu kod parçacağını düzenlemek ve düzenleme ile belirli ID'deki kullanıcıların sayfada çıkmasını engellemek istiyorum. Birkaç şey denesemde başarılı olamadım.

    Desteklerinizi bekliyorum


    /* = Yazarlar
    -------------------------------------------------------------- */
    add_shortcode( 'yazarlar_slider', 'yazarlar_slider_func' );
    
    /* $yazarlar_slider_title = ''; */
    
    function yazarlar_slider_func( $atts, $content = null ) {
    ob_start();
    /* extract(shortcode_atts(array(
    'yazarlar_slider_title' => '',
    ), $atts)); */
    $output ='';
    ?>
    
    <div id="yazarlar-section" data-aos="fade-zoom-in" data-aos-anchor-placement="top-bottom" data-aos-duration="500">
    <div class="container">
    <div class="row">
    <div class="col-md-12">
    <div class="sliderYazarlar-cont">
    <div class="swiper-container yazarlar-container">
    <div class="swiper-wrapper">
    
    <?php
    $authors= get_users('role=author');
    $i=0;
    //get all users list
    foreach($authors as $author){
    $authorList[$i]['id']=$author->data->ID;
    $authorList[$i]['name']=$author->data->display_name;
    $i++;
    }
    ?>
    
    <?php
    foreach($authorList as $author){
    $args=array(
    'showposts'=>1,
    'author'=>$author['id'],
    'ignore_sticky_posts'=>1
    //'tag' => 'yazarlar-anasayfa',
    );
    $query = new WP_Query($args);
    if($query->have_posts() ) {
    while ($query->have_posts()){
    $query->the_post();
    
    $author_id = $author['id'];
    
    ?>
    
    <div class="swiper-slide">
    <div class="yazar-item">
    <?php
    $get_author_gravatar = get_avatar_url($author_id); ?>
    <a href="<?php echo get_author_posts_url($author_id); ?>"><?php echo '<img src="'.$get_author_gravatar.'" />'; ?></a>
    <h3><a href="<?php echo get_author_posts_url($author_id); ?>"><?php echo $author['name']; ?></a></h3>
    <p><a href="<?php echo get_permalink( $query->ID ); ?>"><?php echo get_the_title( $query->ID ); ?></a></p>
    <a href="<?php echo get_author_posts_url($author_id); ?>" class="link-general">Tüm Yazıları</a>
    </div>
    </div>
    
    <?php
    }
    wp_reset_postdata();
    }
    }
    ?>
    
    </div>
    </div>
    <!-- Add Arrows -->
    <div class="button-next button-next-yazarlar"></div>
    <div class="button-prev button-prev-yazarlar"></div>
    </div>
    </div>
    </div>
    </div>
    </div>
    <?php
    $output .= ob_get_clean();
    return $output;
    }




    Yardım edebilecek kimse yok mudur?
  • 27-04-2020, 13:46:53
    #2
    Asagidaki sekilde kullanabilirsin.
    $istenmeyen_uyeler = array(4, 13, 54); buradaki uye id'leri kendine gore degistir.

    /* = Yazarlar
    -------------------------------------------------------------- */
    add_shortcode( 'yazarlar_slider', 'yazarlar_slider_func' );
    
    /* $yazarlar_slider_title = ''; */
    
    $istenmeyen_uyeler = array(4, 13, 54);
    
    function yazarlar_slider_func( $atts, $content = null ) {
    ob_start();
    /* extract(shortcode_atts(array(
    'yazarlar_slider_title' => '',
    ), $atts)); */
    $output ='';
    ?>
    
    <div id="yazarlar-section" data-aos="fade-zoom-in" data-aos-anchor-placement="top-bottom" data-aos-duration="500">
    <div class="container">
    <div class="row">
    <div class="col-md-12">
    <div class="sliderYazarlar-cont">
    <div class="swiper-container yazarlar-container">
    <div class="swiper-wrapper">
    
    <?php
    $authors= get_users('role=author');
    $i=0;
    //get all users list
    foreach($authors as $author){
    $authorList[$i]['id']=$author->data->ID;
    $authorList[$i]['name']=$author->data->display_name;
    $i++;
    }
    ?>
    
    <?php
    foreach($authorList as $author){
    $args=array(
    'showposts'=>1,
    'author'=>$author['id'],
    'ignore_sticky_posts'=>1
    //'tag' => 'yazarlar-anasayfa',
    );
    $query = new WP_Query($args);
    if($query->have_posts() ) {
    while ($query->have_posts()){
    $query->the_post();
    
    $author_id = $author['id'];
    
    if( !in_array($author_id, $istenmeyen_uyeler) ){
    ?>
    
    <div class="swiper-slide">
    <div class="yazar-item">
    <?php
    $get_author_gravatar = get_avatar_url($author_id); ?>
    <a href="<?php echo get_author_posts_url($author_id); ?>"><?php echo '<img src="'.$get_author_gravatar.'" />'; ?></a>
    <h3><a href="<?php echo get_author_posts_url($author_id); ?>"><?php echo $author['name']; ?></a></h3>
    <p><a href="<?php echo get_permalink( $query->ID ); ?>"><?php echo get_the_title( $query->ID ); ?></a></p>
    <a href="<?php echo get_author_posts_url($author_id); ?>" class="link-general">Tüm Yazıları</a>
    </div>
    </div>
    
    <?php
    }
    }
    wp_reset_postdata();
    }
    }
    ?>
    
    </div>
    </div>
    <!-- Add Arrows -->
    <div class="button-next button-next-yazarlar"></div>
    <div class="button-prev button-prev-yazarlar"></div>
    </div>
    </div>
    </div>
    </div>
    </div>
    <?php
    $output .= ob_get_clean();
    return $output;
    }
  • 28-04-2020, 23:34:47
    #3
    orion35 adlı üyeden alıntı: mesajı görüntüle
    Asagidaki sekilde kullanabilirsin.
    $istenmeyen_uyeler = array(4, 13, 54); buradaki uye id'leri kendine gore degistir.

    /* = Yazarlar
    -------------------------------------------------------------- */
    add_shortcode( 'yazarlar_slider', 'yazarlar_slider_func' );
    
    /* $yazarlar_slider_title = ''; */
    
    $istenmeyen_uyeler = array(4, 13, 54);
    
    function yazarlar_slider_func( $atts, $content = null ) {
    ob_start();
    /* extract(shortcode_atts(array(
    'yazarlar_slider_title' => '',
    ), $atts)); */
    $output ='';
    ?>
    
    <div id="yazarlar-section" data-aos="fade-zoom-in" data-aos-anchor-placement="top-bottom" data-aos-duration="500">
    <div class="container">
    <div class="row">
    <div class="col-md-12">
    <div class="sliderYazarlar-cont">
    <div class="swiper-container yazarlar-container">
    <div class="swiper-wrapper">
    
    <?php
    $authors= get_users('role=author');
    $i=0;
    //get all users list
    foreach($authors as $author){
    $authorList[$i]['id']=$author->data->ID;
    $authorList[$i]['name']=$author->data->display_name;
    $i++;
    }
    ?>
    
    <?php
    foreach($authorList as $author){
    $args=array(
    'showposts'=>1,
    'author'=>$author['id'],
    'ignore_sticky_posts'=>1
    //'tag' => 'yazarlar-anasayfa',
    );
    $query = new WP_Query($args);
    if($query->have_posts() ) {
    while ($query->have_posts()){
    $query->the_post();
    
    $author_id = $author['id'];
    
    if( !in_array($author_id, $istenmeyen_uyeler) ){
    ?>
    
    <div class="swiper-slide">
    <div class="yazar-item">
    <?php
    $get_author_gravatar = get_avatar_url($author_id); ?>
    <a href="<?php echo get_author_posts_url($author_id); ?>"><?php echo '<img src="'.$get_author_gravatar.'" />'; ?></a>
    <h3><a href="<?php echo get_author_posts_url($author_id); ?>"><?php echo $author['name']; ?></a></h3>
    <p><a href="<?php echo get_permalink( $query->ID ); ?>"><?php echo get_the_title( $query->ID ); ?></a></p>
    <a href="<?php echo get_author_posts_url($author_id); ?>" class="link-general">Tüm Yazıları</a>
    </div>
    </div>
    
    <?php
    }
    }
    wp_reset_postdata();
    }
    }
    ?>
    
    </div>
    </div>
    <!-- Add Arrows -->
    <div class="button-next button-next-yazarlar"></div>
    <div class="button-prev button-prev-yazarlar"></div>
    </div>
    </div>
    </div>
    </div>
    </div>
    <?php
    $output .= ob_get_clean();
    return $output;
    }
    Hocam çok teşekkürler ama herhangi bir değişiklik olmadı. Gizlemek istediğim kullanıcıların ID'sini giriyorum yine de görüntülemeye devam ediyor.
  • 29-04-2020, 00:08:01
    #4
    MBNS adlı üyeden alıntı: mesajı görüntüle
    Hocam çok teşekkürler ama herhangi bir değişiklik olmadı. Gizlemek istediğim kullanıcıların ID'sini giriyorum yine de görüntülemeye devam ediyor.
    Olmamasi imkansiz. Firsat bulabilirsem deneyecegim
  • 29-04-2020, 05:36:41
    #5
    $istenmeyen_uyeler = array(11, 14, 8); kod öbeğini uygun yere taşıyınca problem çözüldü hocam. Yani şu şekilde:

    <?php
    $istenmeyen_uyeler = array(11, 14, 8);
    $authors= get_users('role=author');
    $i=0;

    İlginiz için teşekkür ederim, çok saolun.