English 中文(简体)
1. 标有元数据
原标题:wordpress custom query with meta data

我正试图获得最新职位,其价值是头盔,但给我以最新的职位。 我在此问,什么是错的?

$querydetails = "
        SELECT $wpdb->posts.* 
        FROM $wpdb->posts, $wpdb->postmeta
        WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id  
        AND $wpdb->postmeta.meta_value =  headline 
        AND $wpdb->postmeta.meta_key =  custom_select 
        AND $wpdb->posts.post_status =  publish 
        AND $wpdb->posts.post_type =  post 
        ORDER BY $wpdb->posts.post_date DESC
        LIMIT 1
    ";

    $headline = $wpdb->get_results($querydetails, OBJECT);
最佳回答

You should do it in wp_query,
The code below should do it.

<?php
$args = array(
     post_type  =>  post ,
     post_status  =>  publish ,
     meta_key  =>  custom_select ,
     meta_value  =>  headline ,
     posts_per_page  =>  1 , //limit
     paged  => get_query_var(  page  ),
     order  =>  DESC ,
     orderby  =>  date 
);
$query = new WP_Query($args);
?>

这样,你就可以在上使用默认字标。

问题回答

暂无回答




相关问题
Wrap stray text in <p> tags

Wordpress issue.. how do I wrap stray text in P tags? Example: Before- <div class = "content"> <img src = "hello.jpg"/> <h1>Introduction</h1> Hello! this is ...

Using jQuery Plugins with Wordpress

Having a bit of trouble using jQuery plugins (Superfish, jQuery UI, etc) using Wordpress. Everything works fine in my plain non-Wordpress site, but Wordpress seems to conflict with JQuery. There must ...

WordPress Data Storage Efficiency

I ve been asked to review a WordPress plugin of sorts and try to find ways of making it faster. The premise of this plugin is basically to store a bunch of users and shifts and appointments and ...

Why can t I properly style a blockquote in Wordpress?

On the design I just created for my website, I have a blockquote styled with two quote images using the span technique in css: blockquote { background-image: url(images/openquote.jpg); background-...

How does the WordPress <!--nextpage--> tag actually work?

What happens? I m guessing that somehow the post or page is parsed before displaying, and then just split into two methods? I can t seem to find any documentation on how the underlying <?php ...

Wordpress Plug-ins: How-to add custom URL Handles

I m trying to write a Wordpress Plug-in but can t seem to figure out how you would modify how a URL gets handled, so for example: any requests made for: <url>/?myplugin=<pageID> will ...

热门标签