• Resolved alx359

    (@alx359)


    Have discovered that the “plugged in” {+product:permalink+} and {+product:post_title+} obstruct the pagination shortcode if injected from a hook, i.e:

    this works:

    [mla_gallery attachment_category=prints-a3 posts_per_page=4 mla_rollover_text="[+product:post_title+]" mla_link_href="{+product:permalink+}"]
    [mla_gallery attachment_category=prints-a3 posts_per_page=4 mla_output="paginate_links,prev_next"]
    

    but a hook like this doesn’t:

    
    add_filter( 'mla_gallery_attributes', 'ew_gallery_attributes', 10, 1 );
    function ew_gallery_attributes( $attr ) {
    if ( !isset( attr['mla_output'] ) ) {
    $attr['mla_rollover_text'] = "{+product:post_title+}";
    $attr['mla_link_href'] = "{+product:permalink+}";
    }
    return $attr;
    }
    

    as it only works on the 1st page, but messing the expanded pagination, like this:

    
    <a class="page-numbers" title="[+product:post_title+]" href="[+product:permalink+]?mla_paginate_current=2" tabindex="-1">2</a>
    

    The behavior is the same with the mla_gallery_raw_attributes hook.

    Bumped into this, as was looking to get boilerplate params consolidated into a hook, to simplify markup across pages and allow tweaking multiple MLA galleries on-the-fly.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for your report and for including your shortcodes and PHP code. I have two answers for you.

    First, I implemented your example on my test system. It failed in the way you describe because of a PHP syntax error:

    if ( !isset( attr['mla_output'] ) ) {

    is missing the dollar sign before attr. The fix I made is:

    if ( !isset( $attr['mla_output'] ) ) {

    Once that was done everything worked for all pages of the gallery.

    Second, you don’t need the filter code at all if you use a custom markup template. You can add your “boilerplate params ” to the template’s Arguments section. Anything you put there will be added to the shortcode parameters of any [mla_gallery] that uses the custom template. That’s a more reliable solution and lets you decide which shortcodes get the boilerplate params.

    Either solution will get you the results you want. I am marking this topic resolved, but please update it if you have any problems or further questions regarding the above suggestions.

    Thread Starter alx359

    (@alx359)

    Thanks! Silly me, it was indeed that typo in my code that the error_log wasn’t catching.

    Thanks for the suggestion of using templates. Haven’t looked much into that yet. MLA has quite a lot of depth and I’ve still much to learn and figure out. In general, like to stuff functions.php as a way to keep all changes in one place and not scattered around.

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

The topic ‘product:permalink from a hook doesn’t paginate’ is closed to new replies.