ansonphong / postworld

Wordpress Theme Development Framework
GNU General Public License v2.0
7 stars 0 forks source link

pw_query() PHP Method - Not querying on post_format #74

Closed ansonphong closed 10 years ago

ansonphong commented 10 years ago

Hi Haidy, I found when querying with pw_query, that post_format isn't returning any results.

Here is an example :

  $query_args = array(
    "post_format" => "video",
    "posts_per_page" => "20"
    );
  $query = pw_query($query_args);
  echo json_encode( $query->posts );

Even if there are some with values 'video', it will not return any results. Totally empty.

Other parameters such as post_class work fine, which are querying form the same wp_postworld_post_meta table.

ansonphong commented 10 years ago

Hi Haidy - do you have any ideas why the post_format hasn't been returning values? Have you been able to re-produce this issue?

hmikhail commented 10 years ago

I used :

$query_args = array(
    "post-format" => "video",
    "posts_per_page" => "20"
    );

and it returned values.

ansonphong commented 10 years ago

Oh that must be it ---

It shoud be "post_format" rather than "post-format"

Different _/-

On 2013-11-24, at 4:30 AM, hmikhail notifications@github.com wrote:

I used :

$query_args = array( "post-format" => "video", "posts_per_page" => "20" ); and it returned values.

— Reply to this email directly or view it on GitHub.

hmikhail commented 10 years ago

Another thing, wp_query generates (0=1) in the query which forces 0 records to be returned. This is because the wp_query uses post_format in the parameters but in tax query

ex:

$args = array(
    'post_type' => 'post',
    'tax_query' => array(
        'relation' => 'OR',
        array(
            'taxonomy' => 'category',
            'field' => 'slug',
            'terms' => array( 'quotes' )
        ),
        array(
            'taxonomy' => 'post_format',
            'field' => 'slug',
            'terms' => array( 'post-format-quote' )
        )
    )
);
$query = new WP_Query( $args );

I tried renaming the column in the database to another dummy name and to "postformat" and no problems occurred and the query returned results. We should change column name and references in the whole plugin. Please confirm.

ansonphong commented 10 years ago

Interesting point - hmm... if we change it to anything, I think we would change it to "link_format" since it currently is being used to define the format of the link_url. that would take some re-implimentation.

please change that to "_linkformat" in the _pwquery(), and I'll change it everywhere else.

On Mon, Nov 25, 2013 at 3:16 AM, hmikhail notifications@github.com wrote:

Another thing, _wpquery generates (0=1) in the query which forces 0 records to be returned. This is because the wp_query uses post_format in the parameters but in tax query

ex:

$args = array( 'post_type' => 'post', 'tax_query' => array( 'relation' => 'OR', array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => array( 'quotes' ) ), array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array( 'post-format-quote' ) ) ));$query = new WP_Query( $args );

I tried renaming the column in the database to another dummy name and to "postformat" and no problems occurred and the query returned results. We should change column name and references in the whole plugin.

— Reply to this email directly or view it on GitHubhttps://github.com/phongmedia/postworld/issues/74#issuecomment-29193923 .

michelhabib commented 10 years ago

Just making sure this one will be covered, as it affects the search results page?

ansonphong commented 10 years ago

I still have to make an across the board change of post_format to link_format

Places to update are :

• Database table : wp_postworld_post_meta column post_format rename link_format • Many functions throughout Postworld via manual search and replace • Post templates

On the search results we can hide this for the next couple days until I've made these changes.