Plugin Directory

Changeset 2754553


Ignore:
Timestamp:
07/11/2022 12:18:15 PM (4 years ago)
Author:
rounakkumar
Message:

Added attribute to show single post by post id.

Location:
posts-by-shortcode
Files:
26 added
2 edited

Legend:

Unmodified
Added
Removed
  • posts-by-shortcode/trunk/posts-by-shortcode-rk.php

    r2747389 r2754553  
    6969    <p><code>[show_posts_pbs_rk layout="1" read_more_lebel="Continue Reading >"]</code> <br><i style="background: #f4f4d4;">Set Custom Label for Read More Button.</i></p>
    7070    <p><code>[show_posts_pbs_rk layout="1" show_author="yes"]</code> <br><i style="background: #f4f4d4;">Show author name in posts.</i></p>
     71    <p><code>[show_posts_pbs_rk layout="1" post_id="52"]</code> <br><i style="background: #f4f4d4;">Show single post by post id.</i></p>
    7172<?php
    7273}
     
    104105    if($atts['show_author']){$show_author = $atts['show_author'];}else{$show_author = 'no';}
    105106   
     107    /* Show Single Post by ID */
     108    if($atts['post_id']){$show_post_by_id = $atts['post_id'];}else{$show_post_by_id = '0';}
     109   
    106110    /* Get Posts Arguments */
    107     $args = array(
    108         'post_type'      => 'post',
    109         'orderby'        => 'ID',
    110         'cat'            => $category_id,
    111         'post_status'    => 'publish',
    112         'order'          => 'DESC',
    113         'posts_per_page' => $post_per_page,
    114         'offset'         => $offset
    115     );
     111    if($show_post_by_id > 0){
     112        $args = array(
     113            'post_type' => 'post',
     114            'post_status' => 'publish',
     115            'p' => $show_post_by_id,
     116        );
     117    }else{
     118        $args = array(
     119            'post_type'      => 'post',
     120            'orderby'        => 'ID',
     121            'cat'            => $category_id,
     122            'post_status'    => 'publish',
     123            'order'          => 'DESC',
     124            'posts_per_page' => $post_per_page,
     125            'offset'         => $offset
     126        );
     127    }
    116128   
    117129    /* Get Posts from Arguments */
  • posts-by-shortcode/trunk/readme.txt

    r2747393 r2754553  
    6565`[show_posts_pbs_rk layout="1" show_author="yes"]`
    6666
     67Show Single post by post id
     68
     69`[show_posts_pbs_rk layout="1" post_id="52"]`
     70
    6771
    6872#### Full Features List:
Note: See TracChangeset for help on using the changeset viewer.