php - WP WordPress 主题问题

标签 php wordpress wordpress-theming

我正在构建一个免费的 WP 主题,但对 PHP 几乎一无所知。我不知道要在这段代码周围放置什么,如果有人可以在它周围放置正确的 PHP 标签,我将非常感激,因为告诉我要放置什么有点像对我说拉丁语。我尝试输入 <?php在开头和 ?>最后但没有成功:

if ( has_post_format( 'aside' ) {
  //  aside format post content here
} else if (has_post_format('gallery')) {
   // stuff to display the gallery format post here
} else if (has_post_format('link')) {
   // link format post content here
} else if (has_post_format('video')) {
   // video format post content here
} else if (has_post_format('audio')) {
   // audio format post content here
} else if (has_post_format('status')) {
   // status format post content here
} else if (has_post_format('chat')) {
   // chat format post content here
} else if (has_post_format('quote')) {
   // quote format post content here
} else if (has_post_format('image')) {
   // image format post content here
}else {
   // code to display the normal format post here
}

最佳答案

放置<?php在每行不包含任何代码的前面(因此以 if 或 } 开头), 并以 ?> 结束这些行.

关于php - WP WordPress 主题问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6710729/

相关文章:

PHP PDO : WHy doesn't work my code to insert multiple rows with different values?

php - ORDER BY 指定顺序

mysql - 两个 MAMP/Wordpress 站点,一个出现 "missing MySQL"错误

html - 如何相对于固定位置的 div 定位 div?

css - 如何摆脱这个元素或改变它的颜色?

PHP正则表达式问题

php - 获取两个连续的日期,它们之间的时间最长

javascript - Ajax 负载使内容加倍

node.js - 无法使用 Wordpress REST API (Node JS) 上传图像文件

Wordpress Docker 不会增加上传限制