• 26-02-2022, 17:13:18
    #1
    Merhaba,

    Firmanin web sitesinde ekip üyeleri için ayrılmış bir sayfa var, ekip üyesinin sayfasının en altında ise yazdığı içerikler yer alıyor (seçiyoruz). Ancak, o içeriğin özeti olarak hepsini aynı çekiyor. Başlık ve linkte sorun yok.

    O içeriğin kısaca özetini çekmesi lazım, 1. içeriği doğru çekmiş ama 2. ve 3. içeriğin özetini olarak aynısını çekiyor.

    Örnek Sayfa: https://www.mgc.com.tr/ekibimiz/ozgun-onal/

    Hata: https://prnt.sc/tflvPK4K5US-
    Hata: https://prnt.sc/sLbwjV-EKNWP
    Nereden çekiyor? https://prnt.sc/mJGyiav4od0m

    single-our-team.php >

    <?php get_header(); wp_reset_query(); ?>
    <main>
        <div class="banner" style="background-image: url(https://www.mgc.com.tr/wp-content/uploads/2021/09/ustbanner.jpg);"></div>
    
            <div class="page-inner team" style="display: block !important;">
                <div class="container">
                    <div class="row">
                        <div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 in detail">                        
                            <div class="member">
                                <div class="row">
                                    <div class="col-12 col-sm-12 col-md-5 col-xl-5">
                                        <figure>
                                            <img class="img-fit" src="<?php the_post_thumbnail_url('full'); ?>" alt="<?php the_title(); ?>">
                                        </figure>
                                    </div>
                                    <div class="col-12 col-sm-12 col-md-6 col-xl-6 offset-1 detail">
                                        <h1><?php the_title(); ?> <?php  echo /* foreach ( get_the_terms( get_the_ID(), 'team-members' ) as $tax ) { echo */ '<span>' . get_post_meta( get_the_ID(), 'teamBranch', true ) .'</span>'; /* } */ ?></h1>
                                        <div class="contact">
                                            T: <a href="tel:<?php echo get_post_meta( get_the_ID(), 'teamTelefon', true ); ?>"><?php echo get_post_meta( get_the_ID(), 'teamTelefon', true ); ?></a><br>
                                            M: <a href="mailto:<?php echo get_post_meta( get_the_ID(), 'teamMail', true ); ?>"><?php echo get_post_meta( get_the_ID(), 'teamMail', true ); ?></a><br>
                                            A: <?php echo get_post_meta( get_the_ID(), 'teamAdres', true ); ?>
    
                                            <div class="social-media">
                                                <?php
                                                    if(!empty(get_post_meta( get_the_ID(), 'teamFacebook', true ))) {
                                                ?>
                                                <a target="_blank" href="<?php echo get_post_meta( get_the_ID(), 'teamFacebook', true ); ?>"><i class="fab fa-facebook-f"></i></a>
                                                <?php } ?>
                                                <?php
                                                    if(!empty(get_post_meta( get_the_ID(), 'teamInstagram', true ))) {
                                                ?>
                                                <a target="_blank" href="<?php echo get_post_meta( get_the_ID(), 'teamInstagram', true ); ?>"><i class="fab fa-instagram"></i></a>
                                                <?php } ?>
                                                <?php
                                                    if(!empty(get_post_meta( get_the_ID(), 'teamWhatsapp', true ))) {
                                                ?>
                                                <a target="_blank" href="<?php echo get_post_meta( get_the_ID(), 'teamWhatsapp', true ); ?>"><i class="fab fa-whatsapp"></i></a>
                                                <?php } ?>
                                                <?php
                                                    if(!empty(get_post_meta( get_the_ID(), 'teamLinkedin', true ))) {
                                                ?>
                                                <a target="_blank" href="<?php echo get_post_meta( get_the_ID(), 'teamLinkedin', true ); ?>"><i class="fab fa-linkedin-in"></i></a>
                                                <?php } ?>
                                                <?php
                                                    if(!empty(get_post_meta( get_the_ID(), 'teamTwitter', true ))) {
                                                ?>
                                                <a target="_blank" href="<?php echo get_post_meta( get_the_ID(), 'teamTwitter', true ); ?>"><i class="fab fa-twitter"></i></a>
                                                <?php } ?>
                                                <?php
                                                    if(!empty(get_post_meta( get_the_ID(), 'teamTelegram', true ))) {
                                                ?>
                                                <a target="_blank" href="<?php echo get_post_meta( get_the_ID(), 'teamTelegram', true ); ?>"><i class="fab fa-telegram-plane"></i></a>
                                                <?php } ?>
                                                <?php
                                                    if(!empty(get_post_meta( get_the_ID(), 'teamTeams', true ))) {
                                                ?>
                                                <a target="_blank" href="<?php echo get_post_meta( get_the_ID(), 'teamTeams', true ); ?>">
                                                    <img class="img-fit" src="https://www.mgc.com.tr/wp-content/uploads/2021/11/teams-icon.png">
                                                </a>
                                                <?php } ?>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <?php the_content(); ?>
                        </div>
                    </div>
                </div>
            </div>
    
            <div class="banner" style="background-image: url(https://www.mgc.com.tr/wp-content/uploads/2021/09/ustbanner.jpg);"></div>
    
            
            <?php
                $posts = get_post_meta( get_the_ID(), 'teamAuthorPost', true );
                if(!empty($posts)) {
            ?>
                <?php if(wp_is_mobile()) { ?>
    
                <div class="bars bars-mobile">
                    <div class="container-fluid">
                        <div class="row">
                            <?php
                                foreach ($posts as $post) {
                                $i = 0;
                                while (have_posts()) : the_post();
                            ?>
                            <div class="col-6 col-sm-6 col-md-6 col-lg-4 col-xl-4 p-0">
                                <div class="bar d-flex align-items-center wow zoomIn" data-wow-delay="<?php echo $i; ?>s">
                                    <a href="<?php the_permalink(); ?>">
                                        <div class="title"><?php echo title_limit(40); ?></div>
                                        <p><?php echo icerik_limit(get_the_content(), 200); ?></p>
                                    </a>
                                </div>
                            </div>
                            <?php $i += 0.10; endwhile; } ?>
                        </div>
                    </div>
                </div>
    
                <?php } else { ?>
    
                <div class="bars">
                    <div class="container-fluid">
                        <div class="row">
                            <?php
                                $i = 0;
                                while (have_posts()) : the_post();
                                foreach ($posts as $post) {
                            ?>
                            <div class="col-6 col-sm-6 col-md-6 col-lg-4 col-xl-4 p-0">
                                <div class="bar d-flex align-items-center wow zoomIn" data-wow-delay="<?php echo $i; ?>s">
                                    <a href="<?php the_permalink(); ?>">
                                        <div class="title"><?php echo title_limit(40); ?></div>
                                        <p><?php echo icerik_limit(get_the_content(), 200); ?></p>
                                    </a>
                                </div>
                            </div>
                            <?php $i += 0.10; } endwhile; ?>
                        </div>
                    </div>
                </div>
                <?php } ?>
            <?php } ?>
        </main>
    <?php get_footer(); ?>
    Sorun nerede anlamadım, bayağı kurcaladım ama çözemedim. Yardımcı olan arkadaşlara şimdiden çok teşekkürler.

    'while(have_posts()) : the_post();' ve '<?php echoicerik_limit(get_the_content(), 200); ?>' > Bu kısımla alakalı olduğunu düşünüyorum.
  • 26-02-2022, 17:18:32
    #2
    the_excerpt() fonksiyonunu neden kullanmıyorsunuz?
  • 26-02-2022, 17:20:21
    #3
    Rawt adlı üyeden alıntı: mesajı görüntüle
    the_excerpt() fonksiyonunu neden kullanmıyorsunuz?
    Merhaba hocam,

    Temayı ben yapmadım. Ben MarCoM'da çalışıyorum. Firma, temayı bir yazılımcı firmaya yaptırmış ancak sonradan yollarını ayırmışlar. Ben de bir miktar anladığım için olan sorunları düzeltmeye çalışıyorum.
  • 26-02-2022, 17:23:33
    #4
    gfo adlı üyeden alıntı: mesajı görüntüle
    Merhaba hocam,

    Temayı ben yapmadım. Ben MarCoM'da çalışıyorum. Firma, temayı bir yazılımcı firmaya yaptırmış ancak sonradan yollarını ayırmışlar. Ben de bir miktar anladığım için olan sorunları düzeltmeye çalışıyorum.
    <?php echo icerik_limit(get_the_content(), 200); ?>
    Yukarıdaki kod yerine aşağıdakini kullanın.

    <?php echo the_excerpt();  ?>
    WordPress yazı özeti çekmenizi sağlayan the_excerpt() fonksiyonunun kelime sayısı varsayılan olarak 55'tir. Kelime sayısı fazla olursa ya da değiştirmek isterseniz aşağıdaki kodları functions.php dosyanıza ekleyin. "return 20" kısmındaki sayıyı dilediğiniz gibi değiştirin.

    function wpdocs_custom_excerpt_length( $length ) {
         return 20;
    }
    add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 );
  • 26-02-2022, 17:31:34
    #5
    Rawt adlı üyeden alıntı: mesajı görüntüle
    <?php echo icerik_limit(get_the_content(), 200); ?>
    Yukarıdaki kod yerine aşağıdakini kullanın.

    <?php echo the_excerpt();  ?>
    WordPress yazı özeti çekmenizi sağlayan the_excerpt() fonksiyonunun kelime sayısı varsayılan olarak 55'tir. Kelime sayısı fazla olursa ya da değiştirmek isterseniz aşağıdaki kodları functions.php dosyanıza ekleyin. "return 20" kısmındaki sayıyı dilediğiniz gibi değiştirin.

    function wpdocs_custom_excerpt_length( $length ) {
         return 20;
    }
    add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 );
    Teşekkürler hocam, problem çözüldü. Biraz çirkin oldu ama problem çözüldü. Aslında bunun için post kısmında excerpt alanı (meta kısmını sanırım) eklenip oraya istenilenin yazılması ve ordan çekilmesi lazım ama öyle bir alan yok tabi.

    Doğru cevap yeşil düğmeye tıkladım ama çalışmıyor sanırım, +R10 verdim.
  • 26-02-2022, 17:35:39
    #6
    @Rawt; Tamamdır, o kısmı da 'özet' kısmından hallettim.