• Resolved salocined

    (@salocined)


    Hi,

    Great plugin.

    I am displaying a FLAG on a post listings using a simple query like
    $the_query = new WP_Query( array(
    'post_type' => 'post',
    'connected_to' => $post->ID
    ) );
    if($the_query->have_posts()) :
    SHOW FLAG

    All is working fine, but I also use a function to allow me to Filter the query by Alphabetical order see function at https://pastebin.com/nwuMV8hG

    When ordering by alphabetical letter, the Connection (connected_to) seems to get lost and my Flag doesn’t display at all.

    any idea?

    thx

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author scribu

    (@scribu)

    You’re hooking into ‘posts_where’, right?

    Thread Starter salocined

    (@salocined)

    Yes Scribu

    Thread Starter salocined

    (@salocined)

    help?

    Thread Starter salocined

    (@salocined)

    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.

    Thread Starter salocined

    (@salocined)

    thx Scribu

    As you said, it’s not lost, but it seems not to do the job required.
    See pastebin link.
    https://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.

    Thread Starter salocined

    (@salocined)

    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
    https://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.

    Thread Starter salocined

    (@salocined)

    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’ ?

    Thread Starter salocined

    (@salocined)

    ??
    you’s the man…

    cheers…
    and well done for everything…clever man.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Connected_to interference’ is closed to new replies.