• Resolved jordiwordpress

    (@jordiwordpress)


    is it possible add a pagination to a each loop results in a Pods template? I only have seen with php o shortcodes.

    Thanks

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @jordiwordpress

    The each loop doesn’t support pagination. You would need to change the each loop to a Pods shortcode and filter the results based on the current field.

    [pods id="{@ID}" name="pod_name" field="rel_field" template="Your loop content template"]

    Sub-shortcodes need to be enabled for this:

    Cheers, Jory

    Thread Starter jordiwordpress

    (@jordiwordpress)

    Hi @keraweb

    It works, the shortcode makes the loop, but don’t display all the fields and the links of the fields either. Does the “Your loop content template” need to be modified?

    Thanks

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @jordiwordpress

    Of course ?? That would be the name of the template in which you have your loop content.
    You cannot use Pods shortcodes within templates since magic tags are parsed before shortcodes. A sub-loop should also be a separate template.

    See: https://docs.pods.io/displaying-pods/pods-shortcode/

    Cheers, Jory

    Thread Starter jordiwordpress

    (@jordiwordpress)

    That would be the name of the template in which you have your loop content.

    I meant the templates’s content, as it only displays the post_title without links or images

    Thanks

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @jordiwordpress

    Assuming that the template exists I would expect that it’s content would be used.

    Could you share your code?

    Cheers, Jory

    Thread Starter jordiwordpress

    (@jordiwordpress)

    Hi @keraweb

            [each foto]
    ?
                <div class="grid-container"> 
                <div class="grid-item pagination"> 
          
    <a href="{@permalink}"><img src="{@post_thumbnail_url._src_relative.sizename}"></a> 
                <div class="desc"><h4>{@post_title} </h4></div>             
          </div>
          </div>
             [/each]   
    
    <style>
    * {
      box-sizing: border-box;
    }?
    .grid-container {    
      width: 33.333%; 
      float: left;  
      padding: 0px 0px 0px 0px;
      object-fit: contain; 
      margin-bottom: 10px; 
    }
    .grid-item {    
    
        height: 240px;
        width: 240px;        
        object-fit: contain;    
    } 
    </style>    
    Thread Starter jordiwordpress

    (@jordiwordpress)

    I have seen it now, If the code is a loop we don’t need the field”” in the shortcode, and works. But I’ve included limit=”6″ pagination=”true” in the shortcode and don’t display pagination.

    Plugin Author Jory Hogeveen

    (@keraweb)

    If you add the field in the Pods shortcode you don’t need the [each] loop anymore as the shortcode already is the eachloop. This is the only way that pagination will work.

    The way you’ve done it now doesn’t change anything from using a regular each loop, you basically just import an extra template.

    The difference is that when you run the Pods shortcode with a field AND template it will load that template using the related object as context instead of the parent object you are including it from.

    Simple example:

    Main template:

    <h1>{@title}</h1>
    {@content}
    <div class="grid-container">
    [pods id="{@ID}" name="pod_name" field="rel_field" template="Loop Template" pagination=1]
    </div>

    Loop template (actual name)

    
    <div class="grid-item pagination"> 
        <a href="{@permalink}">
          <img src="{@post_thumbnail_url._src_relative.sizename}">
        </a> 
        <div class="desc"><h4>{@post_title} </h4></div>             
    </div>
    

    Hope this helps!

    Cheers, Jory

    Thread Starter jordiwordpress

    (@jordiwordpress)

    Hi @keraweb

    Thanks for the codes. The <style> of class=”grid-item-pagination” is width: 33.333%; because is for a grip of 3 columns, with your code only one column displays.

    Thread Starter jordiwordpress

    (@jordiwordpress)

    The css problem is solved, anyway the pagination doesn’t work

    [pods id="{@ID}" name="persona" field="foto" limit="3" template="Foto de persona per Shortcode" pagination="true" pagination="advanced"]  
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @jordiwordpress

    What isn’t working for pagination? Is it not showing at all?

    Cheers, Jory

    Thread Starter jordiwordpress

    (@jordiwordpress)

    Him@keraweb,

    Post are displayed the same as without pagination=”true” pagination=”advanced”

    Nothing involved with the pagination is displayed.

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @jordiwordpress

    I must give you my apologies as the direction I’ve pointed you to apparently doesn’t support pagination (yet).
    The “field” function of a Pod always fetches all relationships and I don’t think it would be a quick fix to support querying by limit and offset.

    There is a different solution however.
    Is this relationship a bi-directional relationship?
    If so, you can query the results the other way around, example:

    [pods name="sub_pod_name" where="bidirectional_relationship_field.meta_value = {@ID}" pagination="advanced" template="Title" limit=5]

    In this case the “{@ID}” magic tag will refer to the current post/object.
    You need to rename “sub_pod_name” and “bidirectional_relationship_field” to the correct field names.

    Hope this helps!

    Cheers, Jory

    Thread Starter jordiwordpress

    (@jordiwordpress)

    Hi @keraweb

    Don’t work. Anyway I want to try with php. Can you share some reference o example?

    Thanks

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Pagination with each loop’ is closed to new replies.