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 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助