mysql - 如何正确匹配标签名称?
问题描述
此代码应将标签名称与表单标题匹配,以输出正确的表单,以允许用户订阅具有当前帖子标签的新帖子。
add_shortcode( 'subscribe-to-the-tag', function() {
global $wpdb, $post;
$the_tag = get_the_tags( $post->ID );
$tag_name = $the_tag[0]->tag_name;
$id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM wptq_forms WHERE name = '{$tag_name}';"));
if (is_null($id)) { return ''; }
return do_shortcode( '[newsletter_form id="' . intval( $id ) . '"]' );
} );
解决方案
推荐阅读
- javascript - 如何将自定义标记添加到 Google 时间轴图表?
- javascript - 对数组进行排序,嵌套所有非唯一值
- python - 使用 Enterprise Architect Python API 旋转标签
- javascript - 处理 JSON 上更改键名的最佳方法是什么?
- python - 使用 pandas 使用 if 条件生成 csv 文件
- json - 在骇客新闻中的颤振小部件测试中,类型“int”不是“String”类型的子类型
- python-3.x - 如何将特定的png文件从一个文件夹编译到另一个文件夹
- mysql - 使用 Laravel 每月向 Mysql 数据库中的列添加值
- c++ - 如何检测传递给 std::bind 的实例已破坏
- java - 打开浏览器和导航 - Java 自动化测试 Selenium