رفتن به مطلب

majidmajid0098

عضو سایت
  • تعداد ارسال‌ها

    67
  • تاریخ عضویت

  • آخرین بازدید

نوشته‌ها ارسال شده توسط majidmajid0098

  1. با سلام من يك كد در قالبم دارم كه مطالب مرتبط از نظر دسته بندي رو نمايش ميدهد .

    حال ميخواهم كد جوري شود كه اگر دسته بندي نبود اين كد نمايش داده نشود :


    <div class="noooooor12">
    <h3> دیدن این مطالب نیز به شما توصیه میشود</h3>
    <?php
    $orig_post = $post;
    global $post;
    $categories = get_the_category($post->ID);

    if ($categories) {
    $category_ids = array();
    foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
    $args=array(
    'category__in' => $category_ids,
    'post__not_in' => array($post->ID),
    'posts_per_page'=>4, // Number of related posts to display.
    'caller_get_posts'=>1
    );

    $my_query = new wp_query( $args );

    while( $my_query->have_posts() ) {
    $my_query->the_post();
    ?>

    <div class="relatedthumb">
    <center><a rel="external" href="<? the_permalink()?>"><?php the_post_thumbnail(array(150,100)); ?><br />
    <?php the_title(); ?></a></center>
    </div>

    <? }
    }
    $post = $orig_post;
    wp_reset_query();
    ?>
    </div>

    ------------

    با تشكر

  2. با سلام من در قالبم از يك كد استفاده مي كنم كه مطالب مرتبط رو به نمايش در مي آورد ( ولي از نوغ برچسب ها تشخيص مي دهد)

    حال من مي خواهم از روي دسته بندي ها مطالب مرتبط نمايش داده بشن

    كد :

    <?php
    $orig_post = $post;
    global $post;
    $tags = wp_get_post_tags($post->ID);

    if ($tags) {
    $tag_ids = array();
    foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
    $args=array(
    'tag__in' => $tag_ids,
    'post__not_in' => array($post->ID),
    'posts_per_page'=>4, // Number of related posts to display.
    'caller_get_posts'=>1
    );

    $my_query = new wp_query( $args );

    while( $my_query->have_posts() ) {
    $my_query->the_post();
    ?>

    ------------------

    با تشكر

×
×
  • اضافه کردن...