如何在标签 [tab] 的短代码之间插入 PHP [英] How to Insert PHP between shortcodes for Tabs [tab]

查看:32
本文介绍了如何在标签 [tab] 的短代码之间插入 PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望获得一些关于如何在我的 2 个标签之间插入我的 php 的帮助.我正在使用 wordpress 并尝试修改模板,以便我的页面上可以有 2 个选项卡,其中包含来自其他两个 php 页面的动态内容.

I am looking to get some help in how to insert my php between my 2 tabs. I am using wordpress and trying to modify a template so that I can have 2 tabs on my page with dynamic content from two other php pages.

我有 2 个标签,但内容没有出现在标签中,而是出现在标签上方.我误认为下面的代码有问题,但我不知道是什么!

I get 2 tabs but the content does not appear in the tabs, but instead above them. I misut be doing something wrong with the code below, but I have no idea what!

我的代码如下:

<?php

echo do_shortcode('[tabs style="boxed"]
[tab title="First Tab"]' .get_template_part("includes/categories-panel"). '[/tab]
[tab title="Second Tab"]'. get_template_part('includes/home-map-panel')  .'[/tab]
[tab title="Third Tab"] Tab 3 Content here [/tab]
[tab title="Fourth Tab"] Tab 4 Content here [/tab]
[/tabs]');

?>

非常感谢任何帮助!

推荐答案

get_template_part 只是当时和那里吐出内容,其中函数需要一个大长字符串.

get_template_part just spits out the content then and there, where the function is expecting a big long string.

您必须捕获输出并将其放入手动.

You'll have to capture the output and put it in manually.

ob_start();
get_template_part("includes/categories-panel");
$cats = ob_get_clean();
ob_start();
get_template_part('includes/home-map-panel');
$home = ob_get_clean();

echo do_shortcode('[tabs style="boxed"]
[tab title="First Tab"]' .$cats. '[/tab]
[tab title="Second Tab"]'. $home  .'[/tab]
[tab title="Third Tab"] Tab 3 Content here [/tab]
[tab title="Fourth Tab"] Tab 4 Content here [/tab]
[/tabs]');

这篇关于如何在标签 [tab] 的短代码之间插入 PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆