-4

最後の行は、機能していない場所です。の代わりに何をすべきかわかりません$post

    if (isset($_COOKIE["WP-LastViewedPosts"])) {
    //echo "Cookie was set.<br/>";  // For bugfixing - uncomment to see if cookie was set
    //echo $_COOKIE["WP-LastViewedPosts"]; // For bugfixing (cookie content)
    $zg_post_IDs = unserialize(preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", stripslashes($_COOKIE["WP-LastViewedPosts"]))); // Read serialized array from cooke and unserialize it
    foreach ($zg_post_IDs as $value) { // Do output as long there are posts
        global $wpdb;
        $zg_get_title = $wpdb->get_results("SELECT post_title FROM $wpdb->posts WHERE ID = '$value+0' LIMIT 1");
        foreach($zg_get_title as $post) {
            echo "<a href=\"". get_permalink($value+0) . "\" title=\"". apply_filters('the_title',$post->post_title) . "\">". apply_filters('the_title',$post->post_title) . "</a> \n"; // Output link and title
            echo implode(', ', $post);
        }
    }
4

1 に答える 1

2

あなたのコメントに基づいて、これを行う1つの方法:

foreach ($zg_get_title as $post) 
{
    $title = apply_filters('the_title', $post->post_title);
    $posts[] = '<a href="'.get_permalink($value).'" title="'.$title.'">'.$title.'</a>';
}

echo implode(', ', $posts);
于 2012-10-12T12:58:56.367 に答える