duanli12176 2017-04-26 15:56
浏览 25
已采纳

Wordpress页面标题 - PHP如果否则

I'm trying to alter my page titles inside my header.php document and need a bit more control over them.

Currently I have an if statement that refers to another bit of PHP that said IF the page is a show page, then display the show name before the title, else do not show anything - meaning it defaults back to the main title code. Heres that code and it works perfectly:

<?php
  if (is_page_template( 'page-show.php' ) ) {
      echo "$show_name -";
  } else {
      echo '';
  }
  ?>

  <?php wp_title( '|', true, 'right' ); ?> Leicester

So, to gain more control over the statement, I would like it to say: IF the page is a show page then display the show name and the normal code for the title, ELSE display just the title code (which I can make different from the show code). I have tried the following, but it doesn;t seem to work - Perhaps I can't include PHP inside echo? Im not sure where the problem is...

<?php
      if (is_page_template( 'page-show.php' ) ) {
          echo "$show_name - <?php wp_title( '|', true, 'right' ); ?> Leicester";
      } else {
          echo '<?php wp_title( '|', true, 'right' ); ?> Leicester';
      }
      ?>

Any ideas?

  • 写回答

2条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 dataframe 某列数据分列
      • ¥15 风扇导入fluent后仿真压力和速度数据卡在旋转域
      • ¥15 echarts中dataZoom报错
      • ¥15 求解答:《前端综合基础》作为一门课程的话,应该包含哪些内容?
      • ¥15 软件原型系统开发+实例测试
      • ¥50 C#上位机调试Win USB
      • ¥15 java基础望榜榜 java基础望榜榜
      • ¥15 comsol 周期性端口
      • ¥15 unity导出微信小游戏的测试中双击未响应
      • ¥15 SPI驱动LORA接收端RF_BUSY