SELECT * FROM $wpdb->posts DOVE ID > 160
8 nov 2014, 15:16:26
Visualizzazioni: 28.5K
Voti: 2
Vorrei recuperare tutti i post e i relativi tag con ID maggiore di 160.
Ho provato:
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 5,
'orderby' => 'ID',
'order' => 'desc',
'meta_query' => array(
array(
'key' => 'ID',
'value' => '160',
'type' => 'numeric',
'compare' => '>',
),
),
);
$the_query = new WP_Query( $args );
Ho provato anche:
$querystr = "
SELECT $wpdb->posts.*
FROM $wpdb->posts, $wpdb->postmeta
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
AND $wpdb->postmeta.meta_key = 'tag'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->posts.post_type = 'post'
AND $wpdb->posts.ID > 160
ORDER BY $wpdb->posts.post_date DESC
";
$pageposts = $wpdb->get_results($querystr);
if ($pageposts): ?>
<?php global $post; ?>
<?php foreach ($pageposts as $post): ?>
<?php setup_postdata($post); ?>
....
Commenti
Tutte le risposte alla domanda
1
0
SELECT * FROM $wpdb->posts
LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)
WHERE $wpdb->posts.post_type = 'post'
AND $wpdb->term_taxonomy.taxonomy = 'post_tag'
AND $wpdb->posts.ID > 160
ORDER BY $wpdb->posts.ID ASC
LIMIT 5
$pageposts = $wpdb->get_results($querystr);
if ($pageposts): ?>
<?php global $post; ?>
<?php foreach ($pageposts as $post):
setup_postdata($post); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<b><a href="<?php the_permalink() ?>" rel="bookmark" title="Link permanente a <?php the_title_attribute(); ?>">
<?php the_title(); ?></a></b>
<small><?php the_time('j F Y') ?> <!-- di <?php the_author() ?> --></small><br/>

Albuquerque Web Design
143
9 nov 2014 10:29:51
Domande correlate
1
risposte
2
risposte