试试这个。希望我正确地解释了您的输出。
我建议你好好读一读$wpdb
法典,尤其是与get_col()
方法-http://codex.wordpress.org/Class_Reference/wpdb#SELECT_a_Column
global $wpdb; // You won\'t need this unless this code is within a function
$query = $wpdb->prepare(
\'SELECT %1$s.guid FROM %1$s\',
$wpdb->posts
);
$results = $wpdb->get_col($query);
$counter = 1; // Ignore this if you already set counter somewhere else, or change it as required
if(!empty($results)) : foreach($results as $result) :
echo \'<div><p>\';
printf(
\'%1$s- %2$s =>\',
$counter,
$result
);
printf(
\'<input class="input_triplify_posts" value="correspondence" id="correspondence%1$s mk="%2$s" />\',
$counter,
$result
);
echo \'</p></div>\';
$counter++;
endforeach;
endif;