0

我正在这个测试网站上工作,这是一个 WordPress 网站(使用 5.5 版)并使用Canvas WooTheme。它的首页应该显示今天的日历事件,这些事件由 WordPress 插件Events Manager提供。

我希望他们做的是显示,例如这个事件页面(以及下面的屏幕截图 - 在这个屏幕截图中看到),确实如此。相反,下面的代码不知何故将模板的其余部分(包括侧边栏)吸进了表格中,继续将表格的行和列复制到自身中(从这个屏幕截图中可以看出)。

它射入 Firebug 的代码如下:

<table cellspacing="0" cellpadding="0" id="current-events"><tbody><tr><td class="startdate_cost_td">
      <span class="start_time"><table cellspacing="0" cellpadding="0" id="current-events"><tbody><tr>
        <td class="startdate_cost_td">
                <span class="start_time">12:00 AM</span><br>
            <span class="cost">Free</span>
        </td>
        <td class="event_image"> <img src="../../../wp-includes/images/default_img.jpg"></td>
        <td class="event_title">Sex Addicts Anonymous meeting<br>
            <i><span class="location_name">@ No location listed</span></i>
            <div id="read_more_wrapper">
            <img src="../../../wp-includes/images/little_pink_arrow.jpg"><a class="pink_link" href="http://testbuzz.illinimedia.com/events/sex-addicts-anonymous-meeting-90">READ MORE</a></div></td></tr>



<!--12:00 AM</span><br/><span class='cost'>Free</span></td><td class='event_image'><img src='../../../wp-includes/images/default_img.jpg' /></td><td class='event_title'><a href="http://testbuzz.illinimedia.com/events/sex-addicts-anonymous-meeting-90" title="Sex Addicts Anonymous meeting">Sex Addicts Anonymous meeting</a><br/><i><span class='location_name'>@No location listed</span></i><br />Mind, body, &amp; spirit<div id='read_more_wrapper'><img src='../../../wp-includes/images/little_pink_arrow.jpg' /><a href='http://testbuzz.illinimedia.com/events/sex-addicts-anonymous-meeting-90' class='pink_link'>READ MORE</a></td></tr></div><tr><td class='startdate_cost_td'>
      <span  class='start_time'>-->
<tr>
        <td class="startdate_cost_td">
                <span class="start_time">8:30 AM</span><br>
            <span class="cost">Free</span>
        </td>
        <td class="event_image"><img alt="&quot;Inside India&quot; with Larry Kanfer" src="http://testbuzz.illinimedia.com/wp-content/uploads/locations-pics/event-35214.jpg"> </td>
        <td class="event_title">“Inside India” with Larry Kanfer<br>
            <i><span class="location_name">@ Alice Campbell Alumni Center</span></i>
            <div id="read_more_wrapper">
            <img src="../../../wp-includes/images/little_pink_arrow.jpg"><a class="pink_link" href="http://testbuzz.illinimedia.com/events/inside-india-with-larry-kanfer-31">READ MORE</a></div></td></tr>

      ......more events similar to this......

<div class="fix"></div>
                                <div class="nav-entries">
                <a href="http://testbuzz.illinimedia.com/page/2"><span class="nav-prev icon fl">Older posts</span></a>                                <div class="fix"></div>
            </div>

                <!-- /#main -->



<div id="sidebar">


    <div class="widget widget_woo_search" id="woo_search-3"><div class="search_main">
    <form action="http://testbuzz.illinimedia.com/" class="searchform" method="get">
        <input type="text" onblur="if (this.value == '') {this.value = 'Search...';}" onfocus="if (this.value == 'Search...') {this.value = '';}" value="Search..." name="s" class="field s">
        <input type="image" name="submit" class="submit" alt="Search" src="http://testbuzz.illinimedia.com/wp-content/themes/canvas/images/ico-search.png">
            </form>    
    <div class="fix"></div>
</div>
       .... the rest of the content stuck .....


</span></td></tr></tbody></table>

下面是我在子主题 template-magazine.php 中插入杂志模板的代码,这导致了问题:

  <?php
                $page = ( !empty($_REQUEST['page']) && is_numeric($_REQUEST['page']) )? $_REQUEST['page'] : 1;
  $args = array( 
               'limit' => 10,
               'scope' => 'today',
               'pagination' => 1
               );

if (isset($_REQUEST['c'])) {
$args['category'] = $_REQUEST['c'];
$args['scope'] = 'future';
}              


$args['offset'] = $args['limit'] * ($page-1);

$events = em_get_events_array($args);
$size = sizeof($events)-1;


echo "<h2 id='headding'class='title'>Today's Events</h2>";
echo "<table cellpadding='0' cellspacing='0' id='current-events' >";

for ($i=0;$i<$size;$i++) {
echo "<tr><td class='startdate_cost_td'>
      <span  class='start_time'>" . $events[$i][0] . 
      "</span><br/><span class='cost'>" . $events[$i][7] . 
      "</span></td><td class='event_image'>";


              if ($events[$i][8] == '') {
            echo "<img src='../../../wp-includes/images/default_img.jpg' />";       
            }
            else {
            echo $events[$i][9];
            }

echo  "</td><td class='event_title'>" . $events[$i][10] .
      "<br/><i><span class='location_name'>@". $events[$i][11] . 
      "</span></i><br />" .$events[$i][12] . 
      "<div id='read_more_wrapper'>" .
      "<img src='../../../wp-includes/images/little_pink_arrow.jpg' /><a href='" . $events[$i][13] . "' class='pink_link'>READ MORE</a></td></tr>" . 
      "</div>";
      } 

echo "</table>";
$last_index = count($events) - 1;
echo $events[$last_index][0];
?>

通过删除代码本身,我确保上面的 PHP 代码是主要问题的原因。这似乎可以解决问题!当我尝试将此代码放在 template-magazine.php 文件的不同部分时,它重复了相同的结果。当我也将它移动到子主题中的 functions.php 文件时,它只是让其他所有内容进一步向下扩展并扩展到浏览器的整个宽度。如何摆脱代码中的循环,将所有的辅助内容都吸入正在创建的表中?

更新:我使用 HTML 标记注释掉了上面的 PHP 代码,复制了事件并注释掉了我们希望在页面上显示的表格元素。下面是它的截图:https ://docs.google.com/open?id=0B2UC67NQiW2yalhMSGxra0FFWGM和下图中显示的代码(我不想粘贴代码,因为它会'已经很久了: 注释掉表格元素,我希望它出现在屏幕上

4

1 回答 1

0

最终它似乎正在阅读我在插件中创建的事件预览设置。我需要做的只是简单地创建一个 for 循环,读取该特定页面的每个事件,屏蔽上面的其余 PHP 代码。以下是用于读取事件的代码:

for ($i=0;$i<$size;$i++) {
    echo $events[$i][0];
}

希望这对使用事件管理器插件的人有所帮助。

于 2012-12-26T19:54:08.800 回答