开发者

In the Wordpress Loop, I want to get the category name that is associated with a page

I'm customizing a wordpress theme and using this plugin, I want pages to display only particular categories, it also allows me to select post-categories in the Page-editor. SEE THIS IMAGE. However, I ended up having to specify such categories in get_post queries within each template page. Here is an example:

<?php       
    $grid_clas开发者_运维知识库ses = 'no-description grid_12 alpha omega';
    $frame_width = 1000;
    $frame_height = 800; 
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;  
    query_posts( array('category' => 'Motion Pictures', 'showposts' => 10 ));               
    if ( have_posts() ) while ( have_posts() ) : the_post(); 

        $video_url = of_get_the_video_url();
        $count++; 

?> 

Is there a way I can retrieve the post-category(ies) that I selected while making the PAGE, so that the templates can be reused with different content? A lot of advanced themes do this, but I can't figure it out. Please help.


You can get category ids(as an array) assigned to post or page by

$categories=wp_get_post_categories($post->ID);


 <?php       
        $grid_classes = 'no-description grid_12 alpha omega';
        $frame_width = 1000;
        $frame_height = 800; 
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;  
        query_posts( array('category' => 'Motion Pictures', 'showposts' => 10 ));               
        if ( have_posts() ) while ( have_posts() ) : the_post(); the_category();

            $video_url = of_get_the_video_url();
            $count++; 

    ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜