-3
最後一行是它不起作用的地方。我不知道應該去那裏,而不是$post
。擺脫尾隨逗號(PHP)
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);
}
}
你到底想幹什麼?需要詳細說明*如何*它不工作。顯示'$ post'的輸出。 –
在我看來,你根本不需要那條線。 –
我想在鏈接後顯示逗號,除了最後一個。 與上述,它根本不顯示逗號。 – Phantasmix