Custom Fields
Re-Envisioned
Support MB Relationships Frontend display of all linked posts in multiple relationships

  • Creator
    Topic
  • #12611
    Resolved Max Elman
    Participant

    This site has CPT “attorney” with multiple linked CPTs “legal news”, “events”, “alerts”, “articles”. I currently have them all displaying in separate lists here: https://cooperwhitecooper.kinsta.com/attorney/sarah-j-banola/

    I’d like to combine the lists for “alerts”, “articles”, and “legal news” and have them display together in chronological order. How can I combine multiple relationship queries like that?

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
    Replies
  • #12616
    Farheen
    Participant

    Hello Max

    Can you please share your code here.

    you want to be able to add “alerts”, “articles”, and “legal news” separately and display them together, is that what you want?

    Thanks

    #12630
    Max Elman
    Participant

    Correct. Current registration code:

    https://ghostbin.com/paste/9x8jp

    #12730
    Max Elman
    Participant

    Hi there – Any chance someone can help resolve this? Thanks!

    #12731
    Anh Tran
    Keymaster

    Hi Max,

    The current version doesn’t support query from multiple relationships at once. However, there’s a workaround. You can make a raw query to get all your connected posts like this:

    https://ghostbin.com/paste/9gfhe

    #12744
    Max Elman
    Participant

    Thanks! This looks close, but breaks the page and throws errors:
    2018/12/20 01:25:39 [error] 61905#61905: *18816 FastCGI sent in stderr: “PHP message: PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function wpdb::prepare(), 1 passed in /www/cooperwhitecooper_161/public/wp-content/themes/cooper-white-cooper/functions.php on line 186 and exactly 2 expected in /www/cooperwhitecooper_161/public/wp-includes/wp-db.php:1222

    Guessing that the << code >> elements shouldn’t be within that wpdb->prepare statement? Can you check that?

    #12747
    Anh Tran
    Keymaster

    I’ve updated the snippet, can you try again?

    #12748
    Max Elman
    Participant

    That worked, thank you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.