drqyxkzbs21968684 2014-11-25 09:33
浏览 15

Wordpress内容博客和使用类别的投资组合

I am in need of some assistance as I am getting into a bit of a tangle with my custom Wordpress theme. what I am trying to achieve is having a standard blog running where I can use the normal features add an image, description tags and also drop it into a category.

I am also wanting to add in a portfolio section also which runs pretty much the same. Now, the way we have approached this is y separating the content using categories, so created one for blog and one for portfolio so that if by chance I want to create some content that would fall under both blog and portfolio it can show in both sections.

I am struggling to understand how to get to that point, I am not looking for any code as such but some suggestion on the best approach.

the way I have currently got this set up is as mentioned above so using categories to separate the content. I am not looking to use plugins either because I want it to all be a true Wordpress custom theme. I had considered using a custom post type which looks like this:

add_action('init', 'register_mypost_type');
function register_mypost_type() {
register_post_type('people',
        array(  'label' => 'Portfolio',
                'public' => true,'show_ui' => true,
                'show_in_menu' => true,
                'capability_type' => 'post',
                'hierarchical' => false,
                'rewrite' => array('slug' => ''),
                'query_var' => true,
                'has_archive' => true,
                'supports' => array('title','editor','thumbnail',),
                'taxonomies' => array('category',),
                'menu_position' => 5,
                ) );
}

Within my functions.php file, however, when trying to show the results because of how the code pulls the posts from the post type its almost like again the categories are seperate from eachother. How would I cross feed them?

            <?php

            $args = array(
                'post_type' => 'Post',
                'cat' => -4,
                'posts_per_page' => 3,
                'post_status' => 'publish',   //or 'draft', 'trash', 'pending', ... 
            );

            $the_query = new WP_Query( $args );

            ?>

The above shows a snippet from my portfolio page, yet by changing only the post_type is not enough because yes it will show posts from that custom post type but the categories are not behaving correctly.

I am really stuck as to wha the best approach is here, so any ideas or thoughts would be much appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?