• 09-04-2020, 06:15:32
    #1
    wordpress yazı içine belirlenen bir etiketteki son yazıyı başlığıyla birlikte nasıl link olarak çekebilirim?

    ÇÖZÜMÜ

    argon adlı üyeden alıntı: mesajı görüntüle
    kodu forum dışından bi arkadaş çözdü sağolsun. eklediğim bu kodu functions dosyasına ekleyip istediğini yazıya [latest_post] ile çağırabilirsiniz. post_per_page, tag, $yaz kısımları değiştirilebilir.
    ben aratıp bulamadım başkası bulsun

    function latest_post() {
    $args = array(
    'posts_per_page' => 1, // we need only the latest post, so get that post only
    'tag' => 'haftalik-burc-yorumlari' // Use the category id, can also replace with category_name which uses category slug
    );
    
    $yaz = "";
    $bloglar = get_posts($args);
    
    foreach($bloglar as $tekli):
    $yaz = $yaz."<a href=\"".get_permalink($tekli)."\">". apply_filters( 'the_title', $tekli->post_title) ."</a>";
    endforeach;
    
    return $yaz;
    }
    
    add_shortcode('latest_post', 'latest_post');
  • 09-04-2020, 06:30:40
    #2
    Üyeliği durduruldu
    argon adlı üyeden alıntı: mesajı görüntüle
    wordpress yazı içine belirlenen bir etiketteki son yazıyı başlığıyla birlikte nasıl link olarak çekebilirim?
    Temanızda bulunan "functions.php" dosyasında en altta bulunan "?>" hemen önce aşşağıdaki kodu yapıştırıp “ETIKET ID” kısmını güncelleyin. Birden fazla etiketi gösterime eklemek için aralarına virgül koyarak 1, 2, 3 şeklinde yazabilirsiniz.


    function etiket_goster($query) {
    if ($query-&gt;is_home()) {
    $query-&gt;set('tag__in', array(ETIKET ID));
    }
    return $query;
    }
    add_filter('pre_get_posts', 'etiket_goster');

    Not: değişiklik yapmadan önce "functions.php" sayfasını yedeklemenizi tavsiye ederim.
  • 09-04-2020, 07:20:24
    #3
    hocam olmadı functions a ekledikten sonra site hata verdi açılmadı, ayrıca bunu seçtiğim yazılara [etiket_goster] diyerek mi çekicem?

    mrsosyal adlı üyeden alıntı: mesajı görüntüle
    Temanızda bulunan "functions.php" dosyasında en altta bulunan "?>" hemen önce aşşağıdaki kodu yapıştırıp “ETIKET ID” kısmını güncelleyin. Birden fazla etiketi gösterime eklemek için aralarına virgül koyarak 1, 2, 3 şeklinde yazabilirsiniz.


    function etiket_goster($query) {
    if ($query-&gt;is_home()) {
    $query-&gt;set('tag__in', array(ETIKET ID));
    }
    return $query;
    }
    add_filter('pre_get_posts', 'etiket_goster');

    Not: değişiklik yapmadan önce "functions.php" sayfasını yedeklemenizi tavsiye ederim.
  • 09-04-2020, 07:34:42
    #4
    <?php query_posts('showposts=5&tag=r10'); ?>

    R10 kısmına etiket adı 5 kısmına da kaç konu çekeceksem yaz hocam.

    Eğer pratik olsun istiyorsan bir function olustur sonr add_shortcode kullan functions dosyana ekle sayfa oluştur oraya shortcode ekle etikete göre gelir. Mobil olduğum için kodu yazamadım.
  • 09-04-2020, 07:46:34
    #5
    hocam dediğin php ile olmadı ama functions la yapacak bi kod buldum. ama sadece başlığı çekebildim linki nasıl çekebilirim

    kod şu şekilde

    function latest_post() {
    $args = array(
    'posts_per_page' => 1, // we need only the latest post, so get that post only
    'cat' => '4' // Use the category id, can also replace with category_name which uses category slug
    );

    $str = "";
    $posts = get_posts($args);

    foreach($posts as $post):
    $str = $str."<h2>". apply_filters( 'the_title', $post->post_title) ."</h2>";
    endforeach;

    return $str;
    }


    DemirayBilisim adlı üyeden alıntı: mesajı görüntüle
    R10 kısmına etiket adı 5 kısmına da kaç konu çekeceksem yaz hocam. Eğer pratik olsun istiyorsan bir function olustur sonr add_shortcode kullan functions dosyana ekle sayfa oluştur oraya shortcode ekle etikete göre gelir. Mobil olduğum için kodu yazamadım.
  • 09-04-2020, 07:48:09
    #6
    argon adlı üyeden alıntı: mesajı görüntüle
    hocam dediğin php ile olmadı ama functions la yapacak bi kod buldum. ama sadece başlığı çekebildim linki nasıl çekebilirim

    kod şu şekilde

    function latest_post() {
    $args = array(
    'posts_per_page' => 1, // we need only the latest post, so get that post only
    'cat' => '4' // Use the category id, can also replace with category_name which uses category slug
    );

    $str = "";
    $posts = get_posts($args);

    foreach($posts as $post):
    $str = $str."<h2>". apply_filters( 'the_title', $post->post_title) ."</h2>";
    endforeach;

    return $str;
    }
    Link için the_permalink() kullanabilirsin hocam
  • 09-04-2020, 07:50:54
    #7
    foreach in içine mi koyucam hocam ? nasıl koyucam?

    DemirayBilisim adlı üyeden alıntı: mesajı görüntüle
    Link için the_permalink() kullanabilirsin hocam




    kodun son hali aşağıdaki şekilde. görünümde ilgili etiketin son postunun başlığını linksiz olarak çekiyor. bunu linkli olarak nasıl çekeceğimi arıyorum

    function latest_post() { 
    $args = array(
    'posts_per_page' => 1, 
    'tag' => 'etiket' );
    
    $str = "";
    $posts = get_posts($args);
    
    foreach($posts as $post):
    $str = $str."<h2>". apply_filters( 'the_title', $post->post_title) ."</h2>";
    endforeach;
    
    return $str;
    }
  • 18-04-2020, 23:03:19
    #8
    kodu forum dışından bi arkadaş çözdü sağolsun. eklediğim bu kodu functions dosyasına ekleyip istediğini yazıya [latest_post] ile çağırabilirsiniz. post_per_page, tag, $yaz kısımları değiştirilebilir.
    ben aratıp bulamadım başkası bulsun

    function latest_post() {  
    $args = array(
    'posts_per_page' => 1, // we need only the latest post, so get that post only
    'tag' => 'haftalik-burc-yorumlari' // Use the category id, can also replace with category_name which uses category slug
    );
    
    $yaz = "";
    $bloglar = get_posts($args);
    
    foreach($bloglar as $tekli):
        $yaz = $yaz."<a href=\"".get_permalink($tekli)."\">". apply_filters( 'the_title', $tekli->post_title) ."</a>";
        endforeach;
    
    return $yaz;
    }
    
    add_shortcode('latest_post', 'latest_post');