petegale
Forum Replies Created
-
Forum: Hacks
In reply to: Custom Taxonomy and Tax_QueryThanks for replying ??
I had tried “include_children” as false before, but the solution you linked seems a little more in depth so I gave it a go.
I’m setting up my query slightly differently to the example, so I changed mine to the following which should hopefully incorporate the proposed solution:
$nextSundayTalkArgs = array( 'post_type' => 'talk', 'posts_per_page' => 1, 'tax_query' => array( array( 'taxonomy' => 'talktype', 'field' => 'slug', 'terms' => 'sunday-talk', 'operator' => 'IN' ), array( 'taxonomy' => 'talktype', 'field' => 'slug', 'terms' => 'sunday-talk', 'operator' => 'IN', 'include_children' => 0 ), 'relation' => 'OR' ) ); $nextSundayTalkQuery = new WP_Query( $nextSundayTalkArgs );
Unfortunately, no luck. I got the same SQL output as before, and no posts ?? If it looks like I haven’t tried the solution properly, please let me know – but it doesn’t seem to have done the trick.
Forum: Hacks
In reply to: Custom Taxonomy and Tax_QueryI mention that
custom_taxonomies_terms_links()
returns the right terms, but forgot to include that function:Forum: Hacks
In reply to: Tax_Query misbehaving in WP_Query(Please feel free to move this thread if I’ve posted in the wrong support category)
A little disappointing, as the only issue I’m having is with Types, so for me it seems related. The rest of my query works perfectly until I try and query the taxonomy (which I’ve created through Types).
I guess it’s time to try a different plugin.
I should probably mention that there’s a date comparison in there now (as it’s coming up in the MySQL). I updated the query to include some date-based filtering:
$nextSundayTalkArgs = array( 'meta_query' => array( array( 'compare' => '>=', 'key' => 'talk-details-date', 'value' => date('U', time()) ) ), 'order' => 'ASC', 'orderby' => 'meta_value', 'post_type' => 'talk', 'posts_per_page' => 1, 'tax_query' => array( array( 'taxonomy' => 'talk-type', 'field' => 'slug', 'terms' => array('sunday-talk'), 'operator' => 'IN' ) ) ); $nextSundayTalkQuery = new WP_Query( $nextSundayTalkArgs );
But it still works if I remove the
tax_query
, and thetax_query
still doesn’t work if I comment out the date filtering, so adding it shouldn’t have been a problem.I got the following (though I should warn you I’m extremely inexperienced with MySQL):
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE 1=1 AND 0 = 1 AND wp_posts.post_type = 'talk' AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') AND ( (wp_postmeta.meta_key = 'talk-details-date' AND CAST(wp_postmeta.meta_value AS CHAR) >= '1359023830') ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date ASC LIMIT 0, 1
If the information from my database tables is somehow wrong, and posts aren’t being allocated the terms properly, is there some way I can clear the taxonomy / terms out of the database fully, and start again to be sure?
Hi Bruce,
As far as I can see, yes. The information I posted above about what’s in the database tables seems to indicate that the posts have the correct taxonomy term.
Just to clarify a few points in case it helps:
The database has a slug of “sunday-talk” in the
wp_terms
table with aterm_id
of 8. Theterm_group
is 0, though I’m not sure what this refers to.The
wp_term_taxonomy
table shows aterm_taxonomy_id
andterm_id
of 8, in the taxonomy “talk-type”, with acount
of 5.The
wp_term_relationships
table shows each of those 5object_id
entries with aterm_taxonomy_id
of 8.So from the database side, everything looks like it’s being added and associated properly.
My full
WP_Query
is:$nextSundayTalkArgs = array( 'post_type' => 'talk', 'posts_per_page' => 1, 'tax_query' => array( array( 'taxonomy' => 'talk-type', 'field' => 'slug', 'terms' => array('sunday-talk'), 'operator' => 'IN' ) ) ); $nextSundayTalkQuery = new WP_Query( $nextSundayTalkArgs );
and works just fine if I comment out the
tax_query
.Can’t spot anything that would be causing a problem, but this is my first week of WP development so I’m still pretty new!
Thanks for your continued help.
Still returns no posts, I’m afraid!
Updated to:
'tax_query' => array( array( 'taxonomy' => 'talk-type', 'field' => 'slug', 'terms' => 'sunday-talk' ) )
Tax Query still isn’t returning any posts, unfortunately. The term is definitely in the database.
Typical, I thought it’d be something daft like that! Thanks for the sanity check ??
Forum: Themes and Templates
In reply to: Adding margin to primary menuHi Raz,
Glad you managed to track it down – self discovery leads to great CSS techniques! ??
You’re very welcome.
Pete.
Forum: Themes and Templates
In reply to: imgleft/right problem: unwanted blank spaceGlad you tracked it down – you’re very welcome!
Forum: Themes and Templates
In reply to: imgleft/right problem: unwanted blank spaceMy guess that somewhere in the stylesheet there’s a clear on the br tag. So something along the lines of:
br { clear: both }
So the br element is clearing, pushing the text after it underneath your floated image.
That’s my guess, anyway.