Wordpress get_post_meta问题

时间:2015-04-12 23:42:54

标签: php wordpress

我是php的新手,并被分配了一些代码来修复Wordpress主题,但我无法解决任何问题。该代码用于自定义主题的主页,它应该提取最新的博客文章并将它们放在页面顶部的3x2网格中。

Here's相关网页

这里是index.php文件中的代码(我相信问题出在哪里)

<?php get_header(); ?>
<?php global $woo_options; ?>
<?php if ( $woo_options['woo_featured_disable'] <> "true" ) include(TEMPLATEPATH . '/includes/featured.php'); ?>
<?php

$t = array();

$t[2] = "A";
$t[5] = "B";

query_posts('post_type=infobox&order=ASC&posts_per_page=20&meta_value=false');

if (have_posts()) :

        $a = array(0,1,3,4); $i = 0;

        while (have_posts()) : the_post();

        $m = "";

        $m .= "<div class=\"bskhp_t\" style='font-family:arial;font-size:12px'>";
        $m .= " <a href=\"".get_post_meta($post->ID, 'mini_readmore', $single = true)."\"><img src=\"".get_post_meta($post->ID, 'mini', $single = true)."\" alt=\"\" class=\"home-icon\"></a>";
        $m .= " <div class=\"bskhp_f\">";
        $m .= "     <h3><a href=\"".get_post_meta($post->ID, 'mini_readmore', $single = true)."\">".get_the_title()."</a></h3>";
        $m .= "     <p>".get_post_meta($post->ID, 'mini_excerpt', true)."</p>";
        $m .= "     <a style='font-family:arial;font-size:13px;text-transform: uppercase' href=\"".get_post_meta($post->ID, 'mini_readmore', $single = true)."\" class=\"btn\">";
        $m .= "     <span>Read More</span></a>";
        $m .= " </div>";
        $m .= "</div>";



        $t[$a[$i++]] = $m;

        endwhile;

endif;

$t[2] = $t[0];
$t[3] = $t[0];
$t[4] = $t[0];
$t[5] = $t[0];

$v = array();

$upload_dir = wp_upload_dir();

$v[] = "<div class=\"bskhp_vpv\"><a href='https://www.plymouthhousing.org/who-we-serve/videos/' style='color:#445567;font-family:arial;font-size:12px;font-weight:500'><img style='padding:4px;border:1px solid #000000; width:180px; height:90px' src='".$upload_dir["baseurl"]."/2015/03/videopreview.jpg' width='180' height='90' vwidth='180' vheight='90' /><div style='color:#000000;font-family:arial;font-size:12px; padding:4px 0'>VIDEO TITLE</div><p style='width:200px'>A local crew in lorem upsum dolor sit amet der despurate...</p></a></div>";
$v[] = $v[0];
$v[] = $v[0];

$p = array();

$p[] = "<div><a href='https://www.plymouthhousing.org/about-us/publications/'><img src='".$upload_dir["baseurl"]."/2015/03/publications_1.jpg' height='254' width='190' /><div class=\"bskhp_pcap\">ANNUAL REPORTS</div></div>";
$p[] = "<div><a href='https://www.plymouthhousing.org/about-us/publications/'><img src='".$upload_dir["baseurl"]."/2015/03/publications_2.jpg' height='254' width='190' /><div class=\"bskhp_pcap\">FACT SHEET &amp; MAPS</div></div>";
$p[] = "<div><a href='https://www.plymouthhousing.org/about-us/publications/'><img src='".$upload_dir["baseurl"]."/2015/03/publications_3.jpg' height='254' width='190' /><div class=\"bskhp_pcap\">NEWSLETTER</div></div>";

$mv = array();

$mv[] = "<h3 class='bskhp_h3'>Our Vision</h3>Housing is just the beginning...the first step to building hope and transforming lives.  We envision a day when every person has a home and a better quality of life.<p class=\"bskhp_rm\"><a href='https://www.plymouthhousing.org/about-us/mission-history/'>READ MORE</a></p>";
$mv[] = "<h3 class='bskhp_h3'>Our Mission</h3>Plymouth Housing Group works to eliminate homelessness and address its causes by preserving, developing and operating safe, quality, supportive housing and by providing homeless adults with opportunities to stabilize and improve their lives.<p class=\"bskhp_rm\"><a href='https://www.plymouthhousing.org/about-us/mission-history/'>READ MORE</a></p>";

?>
<center>
<div id="bskhp_box">

    <!-- tiles -->
    <table style="border-bottom:1px solid #eeeeee; width:945px">
        <tr><td colspan="3"><h3 class="bskhp_h3">Latest News <a style='font-family:arial;font-size:12px;font-weight:500' href="javascript:;"><u>Read more from our blog</u></a></h3></td></tr>
        <tr>
            <td><?php echo $t[0]; ?></td>
            <td><?php echo $t[1]; ?></td>
            <td><?php echo $t[2]; ?></td>
        </tr>
        <tr>
            <td><?php echo $t[3]; ?></td>
            <td><?php echo $t[4]; ?></td>
            <td><?php echo $t[5]; ?></td>
        </tr>
    </table>

    <!-- Two column -->
    <table style="margin:10px 0; padding-bottom:20px; border-bottom:1px solid #e8e4e3">
        <tr>
            <td style="width:710px; padding-bottom:15px">
                <table width="100%" id="bskhp_vids">
                    <tr><td colspan="3"><h3 class="bskhp_h3">Videos <a style='font-family:arial;font-size:12px;font-weight:500' href="https://www.plymouthhousing.org/who-we-serve/videos/"><u>View more of our videos</u></a></h3></td></tr>
                    <tr>
                        <td width="33%" style="padding-bottom:10px; border-bottom:1px solid #e8e4e3"><?php echo $v[0]; ?></td>
                        <td width="33%" style="padding-bottom:10px; border-bottom:1px solid #e8e4e3"><?php echo $v[1]; ?></td>
                        <td width="34%" style="padding-bottom:10px; border-bottom:1px solid #e8e4e3; border-right:1px solid #e8e4e3"><?php echo $v[2]; ?></td>
                    </tr>
                    <tr><td colspan="3" style="padding-top:18px; border-right:1px solid #eeeeee"><h3 class="bskhp_h3">Publications</h3></td></tr>
                    <tr>
                        <td width="33%"><?php echo $p[0]; ?></td>
                        <td width="33%"><?php echo $p[1]; ?></td>
                        <td width="34%" style="border-right:1px solid #e8e4e3"><?php echo $p[2]; ?></td>
                    </tr>
                </table>
            </td>
            <td style="width:234px; border-bottom:1px solid #e8e4e3">
                <?php get_sidebar('home'); ?>
            </td>
        </tr>
    </table>
    <h3 class="bskhp_h3" style="width:945px">Funding Partners</h3>
    <div><img src="<?php echo $upload_dir["baseurl"]."/2015/03/financialpartners.jpg"; ?>" /></div>
    <table>
        <tr>
            <td colspan="2">
                <!-- mission & vision -->
                <table style="width:944px" id="bskhp_mv">
                    <tr>
                        <td id="bskhp_mvl" style="width:50%"><?php echo $mv[0]; ?></td>
                        <td id="bskhp_mvr"><?php echo $mv[1]; ?></td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>

由于某些原因,此代码不会提取最新的博客帖子并将它们放在3x2网格中,除了前两项,我不知道为什么。我相信问题出在get_post_meta函数中,但我的知识太稀疏而无法调试。

有人可以帮忙吗?我会非常亲切:)

0 个答案:

没有答案