Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8257437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:11:49+00:00 2026-06-08T02:11:49+00:00

I am trying to use the Category Posts (WP-CPL) plug-in on a blog I’m

  • 0

I am trying to use the Category Posts (WP-CPL) plug-in on a blog I’m working on to filter ‘Recent Posts’ by category. Basically, when someone clicks on the category name on the blog, I would like it to display the posts from that category. This would be through the ‘archives.php’ file of the Life Is Simple template.

The shortcode for the plug-in is:

[wp_cpl_sc cat_id=40 list_num=4 css_theme=2 sticky_post="79"]

This is just an example where ‘cat_id’ represents the category that the plugin will display. I don’t want to display just one category, I want it to display the appropriate category when someone clicks on the link. How can I get the plug-in to recognize which category is being requested and display the appropriate posts?

I know that the category title is:

<?php single_cat_title(); ?>

But how do I find the category ID number in this fashion? I’ve included the PHP for the plug-in’s file titled ‘wp_cpl_shortcode.php’ below if that needs to be edited. I would prefer to use shortcode in the actual coding of the site for simplicity’s purpose.

<?php
/**
 * shortcode
 * The library of shortcode class
 * @author Swashata <swashata4u@gmail.com>
 * @subpackage WP Category Post List Plugin
 * @version 2.0.0
 */

/**
 * The WP CPL shorttag support
 * @since 1.1.0
 * This was started from the version 1.1.0 and was finished by 2.0.0
 */
class itgdb_wp_cpl_shortcode {
    /**
     * The wp_cpl_shortcode_handler function
     * This function is responsible for converting shortcodes into dynamic contents
     * @package WordPress
     * @subpackage WordPress Category Post List plugin
     * @since 1.1.0
     * @param array $atts The attributes passed through the shortcode
     * @param string $content The string passed through the shortcode. Used for generating title
     * @return string The modified content
     */
    public function wp_cpl_shortcode_handler($atts, $content = null) {
        /** first extract the attributes */
        $op = shortcode_atts(array(
        'cat_id'            => 1,
            'css_theme'                 => 0,
        'is_thumb'          => 'true',
        'list_num'          => 10,
        'show_comments'     => 'true',
        'sort_using'        => 1,
        'sort_order'        => 'asc',
        'exclude_post'      => '',
        'sticky_post'       => '',
            'show_date'                 => 'true',
            'show_author'               => 'true',
            'show_excerpt'              => 'true',
            'excerpt_length'            => 150,
            'optional_excerpt'          => 'false',
            'read_more'                 => __('Continue Reading', itgdb_wp_cpl_loader::$text_domain),
        ), $atts);

        /** Sanitize some of the user datas */
        $cat_id = (int) $op['cat_id'];
        $i = 0;
        /** Done, now the main thing */
        include_once itgdb_wp_cpl_loader::$abs_path . '/includes/wp_cpl_output_gen.php';
        $output_gen = new itgdb_wp_cpl_output_gen();
        return $output_gen->shortcode_output_gen($op);
    }
}

Sorry if this question is convulated, I’m still learning and think I’ve twisted my brain around today. Thanks for any help!


The plug-in page is here:

http://wordpress.org/extend/plugins/wp-category-posts-list/

P.S. I will also post this in the wordpress.stackexchange.com , I just thought maybe this was a good PHP coding question to ask on this forum as well.


EDIT

I tried several things.

Number one:

<?php $categoryid = get_the_category($post->ID);
echo do_shortcode( '[wp_cpl_sc cat_id=".$categoryid." list_num=4 css_theme=2 sticky_post="79"]'); 
?>

This didn’t do anything. It just displayed the first four posts.

Number two (I found a different PHP function in WordPress):

<?php $category_current = get_query_var($cat);
echo do_shortcode('[wp_cpl_sc cat_id="$category_current" list_num=4 css_theme=2 sticky_post="79"]');
?>

I go this idea from here http://www.wpsite.net/how-to-get-category-id-current-category/ . I also tried it as get_query_var(‘cat’) as it says on the site but that didn’t work either. Am I close? Is it a slight matter of syntax? Basically just need to grab the current category ID number and pass it into the ‘cat_id’ part of the shortcode. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:11:51+00:00Added an answer on June 8, 2026 at 2:11 am

    There’s a much easier way to do what I was looking to do (for all those in the future that are looking at this post). I just dynamically called the different elements from the blog through PHP. I set it up first like this:

    <?php
    global $post;
    $category = get_the_category($post->ID);
    $category = $category[0]->cat_ID;
    $myposts = get_posts(array('numberposts' => 5, 'offset' => 0, 'category__in' => array($category), 'post__not_in' => array($post->ID),'post_status'=>'publish'));
    foreach($myposts as $post) :
    setup_postdata($post);
    ?>
    

    And then the different elements to call are the thumbnail image:
    <?php the_post_thumbnail(); ?>

    You can also size the thumbnail like so:
    <?php set_post_thumbnail_size( 300, 300 ); ?>

    The title:
    <?php the_title(); ?>

    And the excerpt:
    <?php the_excerpt(); ?>

    They can be styled by including these elements in divs and styling the divs with sizes thusly. Much easier than trying to change a plugin that’s already hard coded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying use a set of filter functions to run the appropriate routine,
I'm trying to restrict content to posts only from one category. In my loop.php
I'm trying to use a select list to actively filter the results I get
I am trying to use Android's LocationManager requestLocationUpdates. Everything is working until I try
I'm trying to create a simple sorting option for posts in my blog. The
i'm trying use facebook API to upload photo in my fan page. I downloaded
I am trying use gem tire to search in my application. I have tables
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I am trying use a Java Uploader in a ROR app (for its ease

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.