doulian8742 2015-07-13 20:39
浏览 17
已采纳

在创世纪框架wordpress上的特定类别的入口类别之前更改文本

Im trying to change "Filed Under:" for all our service categories and pages (Doors, Flooring, Painting and Windows) the IDs for each categories are as follows 4,5,6,7 and the IDs for each service page is as follows 28,30,32,34.

I got this code from the Studiopress website but it changes all the text before entry-categories globally. I tried to modify it below but its not working.

//* Customize the post meta function
add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
function sp_post_meta_filter($post_meta) {
    if ( !is_page() ) {
        $post_meta = '[post_categories before="Filed Under: "] [post_tags before="Tagged: "]';
        return $post_meta;
    }
}

I have 4 pages (the service pages IDs are above) which are all utilizing a blog template and pulling query_args with cat=ID for each category to showcase the jobs in that category.

I also have a portfolio page (ID=13) to showcase all the jobs associated with the categories above.

Then there is a blog page for company updates and news and will not showcase any jobs (Blog page ID=19). I still want posts on this page to display "Filed Under:".

On the portfolio and service pages I want to change "Filed Under:" to "Service:". I want this change to remain in effect on the actual post of the job as well and on the category page (Im not utilizing the category page but if someone clicks on the service type it will take them there).

I hope this is more clear...

Here is the code I have been playing with and attempting but its still not working. I'm not sure if I'm using the is_page correctly of if i need to be using something else.

//* Customize the post meta function
add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
function sp_post_meta_filter($post_meta) {
    if ( !is_page( array(13,28,30,32,34)) ) {
        if ( !is_category( array(4,5,6,7) ) ) {
            $post_meta = '[post_categories before="Service: "] [post_tags before="Tagged: "]';
        } else { 
            $post_meta = '[post_categories before="Filed Under: "] [post_tags before="Tagged: "]';
        } 
        return $post_meta;  
    }
}
  • 写回答

2条回答 默认 最新

  • dongpu9852 2015-07-16 15:13
    关注

    Thank you Mongjong for putting me on the right path and getting me so far. I was able to tweak your solution a little further to accomplish all my needs! Here is my final code that is working perfectly! :-)

    //* Customize the post meta function
    add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
    function sp_post_meta_filter($post_meta) {
        if((is_page() && in_category(array(4,5,6,7))) || (!is_page() && is_category(array(4,5,6,7))) || (is_single() && in_category(array(4,5,6,7))) || (!is_single() && in_category(array(4,5,6,7))) || (is_page() && get_the_ID() == 13)) {
            $post_meta = '[post_categories before="Service: "] [post_tags before="Tagged: "]';
        }
        else
        {
            $post_meta = '[post_categories before="Filed Under: "] [post_tags before="Tagged: "]';
        }
        return $post_meta;  
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。