• Resolved elizoliva

    (@elizoliva)


    In the documentation you mention that you can have a “Different template per widget / sidebar”. I understand that this is based on the widget id, however I am not understanding how this is applied. In my theme I have a directory ‘acfrpw’ which contains ‘loop-inner.php’. This template works fine to modify ALL acf recent posts widgets, but I would like to specifically target a particular widget. I have the widget id for the specific widget I would like to modify further (widget-1-0-1), but I am not sure how it should be applied to override the default custom template that I already have in place. Should I create another template that uses the widget id in the filename? Or something else? Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter elizoliva

    (@elizoliva)

    I also would like to note that I would like to continue to use my existing ‘loop-inner.php’ across all widgets, I just have one widget in particular where I would like to have something different from the modifications I have made globally.

    Thread Starter elizoliva

    (@elizoliva)

    Nevermind, I figured it out! I just used an ‘if’ statement to declare something different, specific to the widget:

     if ( has_post_thumbnail() and isset( $dth ) and ($acf_rpw_id = "widget-1-0-1") ):
    [all the custom code]
    elseif ( has_post_thumbnail() and isset( $dth ) ):
    [etc...]

    EDIT: Actually, that was not right either. The widget id’s appear to be variable and subject to change based on their order in a sidebar/widget area. They do not have unique ids that necessarily subsist. Instead I am using a custom class to target the widget I need, that works well. So now my if statement is:
    if ( has_post_thumbnail() && ($css == 'MYCUSTOMCLASS') ):
    This may have other issues if say multiple classes are declared in that field, but I am using only one class designation, so it works for my purposes.

    • This reply was modified 7 years, 2 months ago by elizoliva.
    • This reply was modified 7 years, 2 months ago by elizoliva.
    Plugin Author Rafa? Gicgier

    (@gicolek)

    ?? Good job, don’t hesitate to reach out to me if you have any other problems ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Template naming conventions’ is closed to new replies.