• Hello,

    You asked us to provide you with ideas or requests for new types of queries. So this is the issue I would like to resolve.

    BACKGROUND

    I want to add code snippets (queries) in an Elementor pro page/section template. Easy enough to do. Here is some background for the need of a query:

    • I’m sharing a blog and a calendar and I have two custom posts.
    • I’m using Categories to keep each group’s posts in my site separate from one another.
    • Each Elementor template requires the Category to be specified within the template, which means creating a Category for each group. I may have over 1000 groups in the future, which is over 1000 Categories. Who wants to search that list looking for their category?
    • There are 4 post types: Blog, Video, Document, and Calendar. So, that means 1000 Categories times 4 post types to create templates for.
    • Each post type has its own Archive template.

    This will quickly become a performance and maintenance nightmare.

    I want to use a single ADD POSTS template. I DO NOT want the user to select the category, as the category will be system assigned and selecting the correct one will be prone to human error. Example IDs: 116, 128, 668. You get the point.

    SOLUTIONS: QUERY SNIPPETS

    I’m using ACF Frontend to display the ADD & EDIT POST pages, since I don’t want anyone working in the WP-ADMIN panel.

    ADD POSTS QUERY

    I need to query the database to get the GROUP ID based upon the CURRENTLY ACTIVE GROUP. And specify that ID as the Category to use for the post.

    The Author needs to select the post type (see above), so that the correct archive template is selected later. So on the ADD POST page, I need to display post type radio buttons for them to select the correct post type. These will be saved with the POST. When they submit the POST, the Category and post type are now set up.

    EDIT & VIEW POSTS QUERY

    Now, I need to create a snippet (shortcode) to query the posts in my Archive pages. Instead of thousands of templates, I can now display 4 post type Archive pages. The query selects the correct Category, based upon the current group ID of the group the user is in. And the snippet specifies which post type to display within the template.

    WHAT DO YOU THINK OF THE SUGGESTION

    I may have made that seem complicated when it isn’t all that complicated. What do you think? Is this something you think others may need, to limit the number of archive templates needed and to help improve site performance?

    Best Regards,
    Dianne Blake
    Known Universe

    The page I need help with: [log in to see the link]

  • The topic ‘Suggestion: Taxonomy & Database Query’ is closed to new replies.