douxie7339 2015-08-24 15:57
浏览 8
已采纳

Wordpress h1标题PHP条件2

I've the following issue,

http://i.stack.imgur.com/8Zwyj.png

Now as you can see in the image it should show recipes after "Cookies". Now the thing is sometimes the category has Recipes word. for this i'm trying to make php conditioning rule to check if recipes exist in the title then echo nothing else echo recipes.

                        else if( is_archive() ){
                        //echo __('Archive for ', 'recipe'). single_month_title(' ',false);
            echo single_cat_title('Amish '). single_month_title(' ',false). (' Recipes'); 
                    }

This the current code i've here. I need to make (' Recipes') show if it's not exist in the tile otherwise show.

Hopefully that's clear it up.

  • 写回答

1条回答 默认 最新

  • douhoujun9304 2015-08-24 16:27
    关注

    Your question was a little unclear, but I think this is what you were asking for:

    <?php
            if( is_archive() ){
                $current_category = single_cat_title("", false); // Get name of current category
    
                // If current category contains the string "Recipes" don't add it at the end of the name    
                if (strpos($current_category,'Recipes') !== false) {
                    echo single_cat_title('Amish '). single_month_title(' ',false); 
                } else {
                    echo single_cat_title('Amish ') . single_month_title(' ',false) . (' Recipes'); 
                }
    
            }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持