Plugin Author
scribu
(@scribu)
You’re hooking into ‘posts_where’, right?
Any chance for some highlight on this?
Plugin Author
scribu
(@scribu)
The flag is displayed only if you have posts that match both criteria. I don’t think connected_to is ‘lost’; on the contrary.
Add this line before if($the_query->have_posts()) :, to see the final SQL:
var_dump( $the_query->request );
Also, you don’t describe how you order alphabetically.
thx Scribu
As you said, it’s not lost, but it seems not to do the job required.
See pastebin link.
http://pastebin.com/QQi1BScx
First SQL works
All post displayed and connecting flag is displayed when exist.
Second SQL
Displays all post filtered by title LIKE A
But the connection is not shown.
I am using the startwithaction function to drill down by alphabetical letter
thx for looking into it..and sorry if it’s obvious
Plugin Author
scribu
(@scribu)
Ah, you said ‘order’, but you meant ‘filter’.
Displays all post filtered by title LIKE A
But the connection is not shown.
I thought you said you only displayed a flag. What connection do you expect to see?
The problem likely isn’t in the SQL, but in how you’re displaying what you’re trying to display.
Give me the whole story, not just the part that you think is causing the problem.
ok sorry, you’re right
List of country
For each country, articles(post) are “connected”.
So on the listing, I display a link to view articles if a connection is found.
This is working when using the normal listing.
I also use the function startwith..above to filter (sorry) by alphabetical order, so when you click A, you get Australia etc etc.
On this listing my connected article flag is not displaying.
Here’s the code
http://pastebin.com/gL1aH7zn
Plugin Author
scribu
(@scribu)
Ah, I know: The filter on posts_where is affecting all the queries, not just the one you expect.
So, you would only get connected posts that also begin with ‘A’ etc.
You have to remove the filter before doing the connected query. See the remove_filter() function.
should it then be?
global $post;
remove_filter( 'the_content', 'startswithaction' );
$exp_query = new WP_Query( array(
'suppress_filters' => false,
'post_type' => 'post',
'cat' => '1',
'connected' => $post->ID) );
if($exp_query->have_posts()) :
Plugin Author
scribu
(@scribu)
Instead of asking me, just try it.
Sidenote: if the original hook is on ‘posts_where’, why do you attempt to remove it from ‘the_content’ ?
π
you’s the man…
cheers…
and well done for everything…clever man.