add_action和函数无效

时间:2015-09-27 03:56:05

标签: php html wordpress

我添加了以下代码,尝试将表添加到WordPress插件中的现有函数中。

我试图在下面添加的代码只会在我的网站上产生一个空白页面(即不加载)。

代码如下

function my_attendee_form ()
{
    $people = array();
    $EM_Bookings = $EM_Event->get_bookings();
    if (count($EM_Bookings->bookings) > 0) 
    {
        echo "\n";
        ?>
        <table class="event-attendees">
            <tr class="">
                <th class="attendee-name">Name</th>
                <th class="attendee-country">Golf Link</th>
                <th class="attendee-discipline">Handicap</th>
                <th class="attendee-status">Home Club</th>
            </tr>
            <?php
            $guest_bookings = get_option('dbem_bookings_registration_disable');
            $guest_booking_user = get_option('dbem_bookings_registration_user');
            $counter = 0;
            foreach ($EM_Bookings as $EM_Booking) {
                $attendees_list = "";
                $attendees = $EM_Booking->booking_meta['attendees'];
                if (!empty($attendees)) {
                    $attendees_list = "";
                    foreach ($attendees as $key => $value) {
                        foreach ($value as $key_attendee => $value_attendee) {
                            $attendees_list .= "<tr>";
                            $attendees_list .= "<td>".$value_attendee["attendee_name"]."</td>";
                            $attendees_list .= "<td>".$value_attendee["golflink"]."</td>";
                            $attendees_list .= "<td>".$value_attendee["handicap"]."</td>";
                            $attendees_list .= "    <td>".$value_attendee["home_club"]."</td>";
                            $attendees_list .= "</tr>";
                        }
                    }   
                }
                echo $attendees_list;
            }
            echo "\n";
            ?>
        </table>
        <?php
        if (count($EM_Bookings->bookings) == 0) 
        {
            echo '<p>No one registered yet... Will you be the first ?</p>'
        };

有什么建议可能会失败吗?

如果我将代码本身作为HTML div添加到页面中,代码本身就可以工作,但是当我将它作为函数添加到函数中时没有运气。

任何想法都会很棒?

0 个答案:

没有答案