• 16-12-2021, 11:41:35
    #1
    Arkadaşlar wordpress'te benzer yazıları gösterme kodu çalışmasında sıkıntı yok ama başına linklerin başına 1,2,3 diye yazıyor bunu kaldırmak istiyorum. Birde linklerin her birine <h2> tagı versin istiyorum. Nasıl yapabiliirim?

     /** WPT related post widget */
    function wpt_related_posts_cat() {
    if ( is_single ( ) ) {
    global $post;
    $count = 1;
    $postIDs = array( $post->ID );
    $related = '';
    $cats = wp_get_post_categories($post->ID );
    $catIDs = array( );{
    foreach ( $cats as $cat ) {
    $catIDs[] = $cat;
    }
    $args = array(
    'category__in'          => $catIDs,
    'post__not_in'          => $postIDs,
    'showposts'             => 4,
    'ignore_sticky_posts'   => 0,
    'orderby'               => 'rand',
    'tax_query'             => array(
    array(
    'taxonomy'  => 'post_format',
    'field'     => 'slug',
    'terms'     => array(
    'post-format-link',
    'post-format-status',
    'post-format-aside',
    'post-format-quote' ),
    'operator' => 'NOT IN'
    )
    )
    );
    $cat_query = new WP_Query( $args );
    if ( $cat_query->have_posts() ) {
    while ( $cat_query->have_posts() ) {
    $cat_query->the_post();
    $related .= '<li><b>'.$count++.'</b>. &nbsp<a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">' . get_the_title() . '</a></li>';
    }
    }
    }
    if ( $related ) {
    printf( "<div><h3>You'll also like:</h3><ul>%s</ul></div>", $related );
    }
    wp_reset_query();
    }
    }
    add_action( 'genesis_after_entry_content', 'wpt_related_posts_cat' );[COLOR=#000000][FONT="Open Sans"][/FONT][/COLOR]
    Hallettim sanırım arkadaşlar $count = 1; bu kodu kaldırdım ve aşağıdaki kodda değişiklik yaptım.

    $related .= '<h2> &nbsp<a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">' . get_the_title() . '</h2></a>';[COLOR=#000000][FONT="Open Sans"][/FONT][/COLOR]
  • 16-12-2021, 11:43:11
    #2
    ** WPT related post widget */
    function wpt_related_posts_cat() {
    if ( is_single ( ) ) {
    global $post;
    $count = 1;
    $postIDs = array( $post->ID );
    $related = '';
    $cats = wp_get_post_categories($post->ID );
    $catIDs = array( );{
    foreach ( $cats as $cat ) {
    $catIDs[] = $cat;
    }
    $args = array(
    'category__in'          => $catIDs,
    'post__not_in'          => $postIDs,
    'showposts'             => 4,
    'ignore_sticky_posts'   => 0,
    'orderby'               => 'rand',
    'tax_query'             => array(
    array(
    'taxonomy'  => 'post_format',
    'field'     => 'slug',
    'terms'     => array(
    'post-format-link',
    'post-format-status',
    'post-format-aside',
    'post-format-quote' ),
    'operator' => 'NOT IN'
    )
    )
    );
    $cat_query = new WP_Query( $args );
    if ( $cat_query->have_posts() ) {
    while ( $cat_query->have_posts() ) {
    $cat_query->the_post();
    $related .= '<li><h2>Burası Kullanılacak Alan</h2><a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">' . get_the_title() . '</a></li>';
    }
    }
    }
    if ( $related ) {
    printf( "<div><h3>You'll also like:</h3><ul>%s</ul></div>", $related );
    }
    wp_reset_query();
    }
    }
    add_action( 'genesis_after_entry_content', 'wpt_related_posts_cat' );
    Bu şekilde dener misiniz bir de
  • 16-12-2021, 12:00:42
    #3
    Hocam istediğim h2'yi linklere vermek yukarda yaptım sanırım count kaldırdım şu an çalışıyor.

    SarSeoAgency adlı üyeden alıntı: mesajı görüntüle
    ** WPT related post widget */
    function wpt_related_posts_cat() {
    if ( is_single ( ) ) {
    global $post;
    $count = 1;
    $postIDs = array( $post->ID );
    $related = '';
    $cats = wp_get_post_categories($post->ID );
    $catIDs = array( );{
    foreach ( $cats as $cat ) {
    $catIDs[] = $cat;
    }
    $args = array(
    'category__in'          => $catIDs,
    'post__not_in'          => $postIDs,
    'showposts'             => 4,
    'ignore_sticky_posts'   => 0,
    'orderby'               => 'rand',
    'tax_query'             => array(
    array(
    'taxonomy'  => 'post_format',
    'field'     => 'slug',
    'terms'     => array(
    'post-format-link',
    'post-format-status',
    'post-format-aside',
    'post-format-quote' ),
    'operator' => 'NOT IN'
    )
    )
    );
    $cat_query = new WP_Query( $args );
    if ( $cat_query->have_posts() ) {
    while ( $cat_query->have_posts() ) {
    $cat_query->the_post();
    $related .= '<li><h2>Burası Kullanılacak Alan</h2><a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">' . get_the_title() . '</a></li>';
    }
    }
    }
    if ( $related ) {
    printf( "<div><h3>You'll also like:</h3><ul>%s</ul></div>", $related );
    }
    wp_reset_query();
    }
    }
    add_action( 'genesis_after_entry_content', 'wpt_related_posts_cat' );
    Bu şekilde dener misiniz bir de