• Resolved smatzis

    (@smatzis)


    Hello and many thanks for this wonderful plugin!
    Is there a way to exclude the rendering of the current post from the loop of a customized pods query (relation from current item) in the posts module of beaver builder?

    Many thanks in advance!

    The following code excludes current posts from custom queries but not from pods relationsip queries:
    function uabb_advance_post_custom_args( $args ) {
    $args[‘post__not_in’] = array( get_the_ID() );
    return $args;
    }
    add_filter( ‘uabb_blog_posts_query_args’, ‘uabb_advance_post_custom_args’, 10, 1 );

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Bernhard Gronau

    (@quasel)

    Sorry for the late reply – not sure I understand why you would need that in the first place? why would you set a relation that points back to the post itself – what’s the use case?

    If you need to tamper with the query of the default BB Posts Module take look at the fl_builder_loop_before_query_settings filter or change the query afterwards

    I hope this did help!

    Bernhard

    Thread Starter smatzis

    (@smatzis)

    Thank you for your answer. Sorry i did not provide enough information in the first place.
    Well, i have 2 pods: books and authors. There are relationship fields for books->authors and authors->books written.
    i have created a singular theme layout for book-template and i want to have a row under the book image and info that shows other books by this author.
    So i use BB Posts Module and i select customized pods query -> relation from current item to show the books written by the author of the current book displaying.
    The problem is that this method displays all the books written by the author and it does not exclude the current book displaying.
    This is the problem!
    The above filter (that i added in the functions.php) excludes current posts from normal queries but not posts deriving from relationships’ queries!
    If you have any idea how to accomplish this using BB Posts Module i would be more than grateful…

    • This reply was modified 8 years ago by smatzis.
    Plugin Contributor Bernhard Gronau

    (@quasel)

    Ahh that makes perfect Sense! unfortunate this isn’t easily done without some code – need to hink about it – this is configured as a bidirectional relationship right? can a book have multiple authors?

    Which Template Code (pods or BB) do you currently use to output the list?
    Just to find the easiest way if possible ^^

    Thread Starter smatzis

    (@smatzis)

    Thank you Bernhard. I am really glad you understand the problem and want to help. In order to donate to this plugin, should someone donate to pods.io?

    Correct, it is a bidirectional field. However one book does not have many authors. Only an author may have many books.
    The custom html layout that i use for single post rendering in BB’s post grid is:

    [wpbb-if post:featured_image]
    <div class="uabb-post-thumbnail uabb-blog-post-section uabb-archive_grid-image">
    	[wpbb post:featured_image size="large" display="tag" linked="yes"]
    </div>
    [/wpbb-if]
    
    <div class="uabb-archive_grid-title">
    <h3 class="uabb-post-heading uabb-blog-post-section">[wpbb post:link text="title"]</h3>
    </div>
    
    [pods]
        <h5 class="uabb-archive_grid-author uabb-blog-post-section">
            <a href="{@permalink}">{@book_author}</a>
        </h5>
    [/pods]

    Hope that helped!

    • This reply was modified 8 years ago by smatzis.
    • This reply was modified 8 years ago by smatzis.
    Thread Starter smatzis

    (@smatzis)

    Thank you Bernhard. I am really glad you understand the problem and want to help. In order to donate to this plugin, should someone donate to pods.io?

    Correct, it is a bidirectional field. However one book does not have many authors. Only an author may have many books.
    The custom html layout that i use for single post rendering in BB’s post grid is:

    [wpbb-if post:featured_image]
    <div class=”uabb-post-thumbnail uabb-blog-post-section uabb-archive_grid-image”>
    [wpbb post:featured_image size=”large” display=”tag” linked=”yes”]
    </div>
    [/wpbb-if]

    <div class=”uabb-archive_grid-title”>
    <h3 class=”uabb-post-heading uabb-blog-post-section”>[wpbb post:link text=”title”]</h3>
    </div>

    [pods]
    <h5 class=”uabb-archive_grid-author uabb-blog-post-section”>
    <a href="{@permalink}">{@book_author}</a>
    </h5>
    [/pods]

    Hope that helped!

    • This reply was modified 8 years ago by smatzis.
    Plugin Contributor Bernhard Gronau

    (@quasel)

    Sorry really busy week here – need to dig into pods code if there is an easy way to filter this or adapt the integration – in the end it’s about excluding the current id from the pods query … thought It might be easier still feel it should but maybe I just don’t see it :/

    Thread Starter smatzis

    (@smatzis)

    OK no problem! I hope you are healthy and happy! Many thanks for the digging!
    If this makes sense, i think it’s about excluding the current id from the relation of the current pods query.
    In the end, i hope that more people make use of this kind of filters for their projects and understand how to make advanced queries and filtering! Maybe it could help pods shine a little more too!!

    Plugin Contributor Bernhard Gronau

    (@quasel)

    Best would be to keep track of this if you open an issue at GitHub – https://github.com/pods-framework/pods-beaver-builder-themer-add-on/issues

    I plan to take a look at it next week!

    Thread Starter smatzis

    (@smatzis)

    Ok Bernhard i have opened a new issue at GitHub. Thanks again!

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘customized pods query’ is closed to new replies.