Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在WordPress短代码中显示PHP自定义字段_Php_Wordpress_Wordpress Theming_Shortcode - Fatal编程技术网

在WordPress短代码中显示PHP自定义字段

在WordPress短代码中显示PHP自定义字段,php,wordpress,wordpress-theming,shortcode,Php,Wordpress,Wordpress Theming,Shortcode,我正在使用echo do_shortcode函数在WP模板中包含事件日历。我需要在快捷码区域内显示自定义字段,但无法使其工作。下面是我的代码。我需要在a href=“#”部分显示自定义字段“tickets”(替换#) 帖子是一种称为“事件”的自定义帖子类型 首先获取自定义字段并将其保存在变量中。您可以稍后在字符串中使用该变量 <?php $url = get_post_meta($post_id, 'tickets', true); echo do_shortcode('[eo_event

我正在使用
echo do_shortcode
函数在WP模板中包含事件日历。我需要在快捷码区域内显示自定义字段,但无法使其工作。下面是我的代码。我需要在
a href=“#”
部分显示自定义字段“tickets”(替换#)

帖子是一种称为“事件”的自定义帖子类型


首先获取自定义字段并将其保存在变量中。您可以稍后在字符串中使用该变量

<?php
$url = get_post_meta($post_id, 'tickets', true);
echo do_shortcode('[eo_events] 
<div class="date"><div class="month">%start{M}%</div> <div class="day">%start{j}%</div></div> <div     class="venue"><h2 style="margin-bottom:-40px!important; padding-bottom:0;">%event_venue%</h2> <    br/>    %event_venue_address%<br/>%event_venue_country%, %event_venue_postcode%</div> <div class="city"    ><h2    >%event_venue_city%</h2></div> <div class="tickets">    
<h2><a href="'.$url.'" target="_blank">Tickets</a></h2>    
</div>    
[/eo_events]');
?>

?不幸的是,这没有起到任何作用。我也尝试过下面@Gerald Schneider的答案,但也没有成功。谢谢-但是,当我将鼠标悬停在“票证”链接上时,它只链接到同一页面,而不是在“自定义字段”框中输入的URL。
<?php
$url = get_post_meta($post_id, 'tickets', true);
echo do_shortcode('[eo_events] 
<div class="date"><div class="month">%start{M}%</div> <div class="day">%start{j}%</div></div> <div     class="venue"><h2 style="margin-bottom:-40px!important; padding-bottom:0;">%event_venue%</h2> <    br/>    %event_venue_address%<br/>%event_venue_country%, %event_venue_postcode%</div> <div class="city"    ><h2    >%event_venue_city%</h2></div> <div class="tickets">    
<h2><a href="'.$url.'" target="_blank">Tickets</a></h2>    
</div>    
[/eo_events]');
?>