Query Category Post by Post Slug

Add This to function.php
    function the_slug() {
    $post_data = get_post($post->ID, ARRAY_A);
    $slug = $post_data['post_name'];
    return $slug; }

This is How to dispay the text of the current post slug in your Custom Wordpress Theme

<?php echo the_slug(); ?>

This is How to Query Post by Slug
The TRICK is to create a Category that's the same name to Post Slug

<?php  query_posts('posts_per_page=30' . '&category_name='.the_slug()); ?>

No comments:

Post a Comment