我想知道如何在获取标题时应用php字符串: 离。
<h1 class="page-title"><?php single_cat_title(__('category:','themename')); ?></h1>
因此,如果标题是“视频”,则内容中的按钮将更改为“立即观看”,而不是默认的“阅读更多”。
类似
if title is = "video's" {
echo "<button>Watch now</button>"
}<button>Readmore</button>
答案 0 :(得分:0)
这里有适合你的代码
if (single_cat_title("",false) == "video's") {
echo "<button>Watch now</button>"
} else {
echo "<button>Readmore</button>"
}
我只是假设该标题实际上名为视频
答案 1 :(得分:0)
以下是基本方法,即使使用类别名称,您也可以通过它的类别ID查看视频帖子。这是示例代码。
$category_id = get_cat_ID('Category Name');
if( $category_id == 'your cat id'){
echo 'watch video';
{
else{
echo 'readmore';
}
希望它有所帮助。干杯!
答案 2 :(得分:0)
您需要if (single_cat_title("", false) == "video's") {
echo "Watch now";
} else {
echo "Read more";
}
作为第二个参数才能返回值(不打印)。然后再比较一下。
from PyQt5.QtWidgets import (QMessageBox,QApplication, QWidget, QToolTip, QPushButton,
QDesktopWidget, QMainWindow, QAction, qApp, QToolBar, QVBoxLayout,
QComboBox,QLabel,QLineEdit,QGridLayout,QMenuBar,QMenu,QStatusBar,
QTextEdit,QDialog,QFrame,QProgressBar
)
from PyQt5 import QtCore, QtWidgets, QtGui
from PyQt5.QtGui import QIcon,QFont,QPixmap,QPalette
from PyQt5.QtCore import QCoreApplication, Qt,QBasicTimer
import sys
class cssden(QMainWindow):
def __init__(self):
super().__init__()
self.mwidget = QMainWindow(self)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
#size
self.setFixedSize(320, 450)
self.center
#label
self.lbl = QLabel(self)
self.lbl.setText("test")
self.lbl.setStyleSheet("background-color: rgb(0,0,0);"
"border: 1px solid red;"
"color: rgb(255,255,255);"
"font: bold italic 20pt 'Times New Roman';")
self.lbl.setGeometry(5,5,60,40)
self.show()
#center
def center(self):
qr = self.frameGeometry()
cp = QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
self.move(qr.topLeft())
app = QApplication(sys.argv)
app.setStyleSheet("QMainWindow{background-color: darkgray;border: 1px solid black}")
ex = cssden()
sys.exit(app.exec_())