I am trying to use the Category Posts (WP-CPL) plugin on a blog that I am working on to filter Recent Posts by category. Basically, when someone clicks on a category’s name on a blog, I would like it to display posts from that category. This will be through the "archives.php" file of the Life Is Simple template.
Barcode for the plugin:
[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 show only one category, I want it to display the corresponding category when someone clicks on a link. How can I make the plug-in recognize which category is being requested and display the appropriate messages?
I know the name of the category:
<?php single_cat_title(); ?>
But how do I find the category identifier this way? I have included PHP for the include file called "wp_cpl_shortcode.php" below if it needs to be edited. I would prefer to use short code in the actual coding of the site for simplicity.
<?php
class itgdb_wp_cpl_shortcode {
public function wp_cpl_shortcode_handler($atts, $content = null) {
$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);
$cat_id = (int) $op['cat_id'];
$i = 0;
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 concretized, I am still participating and I think that today I was spinning my brain. Thanks for any help!
The plugin page is here:
http://wordpress.org/extend/plugins/wp-category-posts-list/
P.S. wordpress.stackexchange.com, , , PHP, .
.
:
<?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"]');
?>
. .
( PHP 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"]');
?>
http://www.wpsite.net/how-to-get-category-id-current-category/. get_query_var ('cat'), , . ? ? "cat_id" . .