• Resolved netschmiede24

    (@netschmiede24)


    Hi there,

    I am in the process of setting up a website for a travel agency. The trips they are offering are added via an API to a custom post type, which I have extended with pods for some additional taxonomies. One of them is “country”, which obviously has over 200 values for each country in the world. So far, so good.

    Now I have set up a page which lists ALL of the countries alphabetically with this template:

    <a href="reisen/?filter_trip_country_continent={@term_id}">
    <span class="filter-name">{@name} ({@count})</span>
    </a><br />

    In the output, I noticed that some of the country-lists have trips, which do not belong to that specific category. Upon investigation, it seems that for example https://domain/reisen/?filter_trip_country_continent=98 lists the trips which have South Africa (term ID 98) as their taxonomy – but also the ones, which have Malta (term ID 198). So it seems, that “filter_trip_country_continent={@term_id}” takes all term IDs, which contain that specific number, but not just those where the ID matches exactly the number.

    What do I have to do to make Malta trips not appear on the South Africa page…. ?

    Thanks,
    Astrid

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Paul Clark

    (@pdclark)

    Search/filter is for searching within text, while filtering by taxonomies is a feature built into WordPress core templates and database structure.

    With WordPress Archive Pages

    The easiest approach would be to use the archive pages for taxonomy terms which are auto-generated by WordPress.

    See https://developer.www.ads-software.com/themes/basics/template-hierarchy/ for template structure which applies to most themes.

    Pods Auto Template option can also add content to most theme taxonomy term archive pages if they display an archive term description.

    With Pods WHERE Filter

    Another option would be use the WHERE option of a Pods Item list block or Pods shortcode to filter to a taxonomy ID or slug name defined in the URL.

    Setup: add define( 'PODS_SHORTCODE_ALLOW_EVALUATE_TAGS', true ); to wp-config.php

    List all posts assigned to a certain country, e.g., placed on the /reisen/ page:

    [pods name="post" where="country.term_id = {@get.country}"]
    <a href="{@permalink}">{@post_title}</a>
    [/pods]

    List all countries with links to filter on the /reisen/ page:

    [pods name="country"]
    <a href="/reisen/?country={@term_id}">{@name}</a>
    [/pods]
    Thread Starter netschmiede24

    (@netschmiede24)

    Hi,

    thanks for getting back to me about this. I found an “archive.php” in my theme – and I can copy it to a “taxonomy.php” in my child theme and then add stuff to it, so the output will change. But I am still not understanding how to modify the output to a template I created with pods.

    Right now the part of the loop for the archive looks like this:

    get_template_part( 'loops/loop', 'blog-' . siteorigin_setting( 'blog_archive_layout' ) );

    I have a pod template called “Reise-Liste” which I would prefer as a loop. What do I change to make my template the default?

    Thanks,
    Astrid

    Plugin Support Paul Clark

    (@pdclark)

    See https://docs.pods.io/code/pods/template/

    echo pods()->template( 'Reise-Liste' );

    When passed no arguments, pods() should use the arguments of the current template. If not, see the examples for passing arguments for the pod_name/taxonomy_name as well as pagination.

    See https://docs.pods.io/code/pods/find/ for options for $params as seen in the ->template() method examples.

    Thread Starter netschmiede24

    (@netschmiede24)

    echo pods()->template( 'Reise-Liste' );

    This will only display the template ONCE. I need to display it in a LOOP for every item in the loop.

    So I need to find how to change the last line of this code here:

    /* Start the Loop */
    while ( have_posts() ) {
    the_post();
    get_template_part( 'template-parts/content', get_post_format() );

    If I use echo pods … then this will not fill in the content from the post custom type.

    Plugin Support Paul Clark

    (@pdclark)

    It should echo for the current global post object and global post type within the loop:

    /* Start the Loop */
    while ( have_posts() ) {
    the_post();
    echo pods()->template( 'Reise-Liste' );
    }

    If it does not, the long-form would be:

    /* Start the Loop */
    while ( have_posts() ) {
    the_post();
    echo pods( 'name_of_post_type', get_the_ID() )->template( 'Reise-Liste' );
    }
    Thread Starter netschmiede24

    (@netschmiede24)

    ah yes – the long form works.

    Any idea how I can sort the results randomly ?

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