• Resolved kidznc

    (@wsp-kk)


    Hello!

    We’re presently attempting to create a loop of file downloads from another plugin (Download Manager) that generates its own custom post type (dlm_download). We have a bit of a mix between custom Bootstrap-based .PHP template files and Page Builder to allow for some freedom of layout, but also heavy customization.

    While we’d usually run a PHP-based query in one of the templates, the particular layout of this page requires doing so via Page Builder; hence the use of the Post Loop widget. Unfortunately the CPT created by the download plugin is not showing up in the Post Type options.

    We’re all set up to add an action to change the $args on this post type in order to force it to show up (as below):

    add_action('register_post_type_args', function ($args, $postType) {
    if ($postType !== 'dlm_download'){
    return $args;
    }
    $args['ExampleArgument'] = ArgumentSetting;
    return $args;
    }, 99, 2);

    …but instead of cycling through every possible option, we thought it would be easier to ask what arguments are necessary to get this CPT to pop up in the Post Loop > Post Type options.

    P.S.: We tried public => true, but encountered a server loop (possibly because we’re trying to run it as an mu-plugin; haven’t checked yet).

    Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Andrew Misplon

    (@misplon)

    Hi, thanks for getting in touch. It is necessary to set public to true. Unfortunately, I’m not sure why you ran into an error. Was there perhaps anything in the debug file when the loop occurred?

    Thread Starter kidznc

    (@wsp-kk)

    Thank you, Andrew – this is what I needed to know. At least I know I’m working in the right direction. I haven’t had time to return to it, but I’ll check php_error_log and also WordPress’ own debug log.

    Will report back when I figure it out (and I might just inquire with the authors of Download Monitor if I can’t figure it out). Will be in touch.

    • This reply was modified 2 months, 2 weeks ago by kidznc.
    Plugin Support Andrew Misplon

    (@misplon)

    Sounds like a plan. All the best with your troubleshooting. Cheers.

    Thread Starter kidznc

    (@wsp-kk)

    Problem solved. It wasn’t the change in $args causing the problem (it shows up fine now); it’s the loop-within-a-loop that comprises the Bootstrap-based container being used as a template.

    I don’t have any problems running this as a secondary template file within a WP_Query, but the Post Loop widget doesn’t want to have anything to do with the While/End While statement that’s run inside the file to ensure that a Bootstrap row is created after every three images.

    <?php $counter = 1; ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <?php
    if ( $counter % 2 == 1 ) {
    echo '<div class="row row-flex-box">';
    }
    ?>
    <div class="col-sm-4">
    <a href="<?php the_permalink(); ?>">
    <?php echo get_the_post_thumbnail( get_the_ID(), 'large', array( 'class' => '' ) ); ?>
    </a>
    <p></p>
    <a type="button" class="btn btn-lg" href=<?php the_permalink(); ?>>Download - <?php the_title(); ?></a>
    </div>
    <?php
    if ( $counter++ % 2 == 0 ) {
    echo '</div>';
    }
    ?>
    <?php endwhile; ?>

    Would you know of a way to get this to work within the Post Loop widget?

    I don’t think I can nest this in another template without that template called over for each item in the loop.

    Thanks!

    Plugin Support Andrew Misplon

    (@misplon)

    Super; really glad to hear you’re making progress.

    We’re unfortunately quite limited as to how involved we can get in custom development tasks within our free support. We do the best we can with the budget we have and can perhaps offer some top level advice or queries. Are you perhaps able to spot anything useful looking at the way Vantage adds loop files that are compatible with the Post Loop Widget? You can view a template here.

    Thread Starter kidznc

    (@wsp-kk)

    Solved it. I added “row” to the widget.

    Here’s the new template file:

    <?php /* Variation of three-column loop - use only with Site Origin Post Loop Widget
    Apply "row" CSS to widget for proper functionality */ ?>

    <div class="col-12 col-lg-4 pb-2">
    <a href="<?php the_permalink(); ?>">
    <?php echo get_the_post_thumbnail( get_the_ID(), 'large', array( 'class' => '' ) ); ?>
    </a>
    <p></p>
    <a type="button" class="btn btn-lg" href=<?php the_permalink(); ?>><?php the_title(); ?><p></p>Download</a>
    </div>

    /done ??

    Plugin Support Andrew Misplon

    (@misplon)

    Great result! Thanks for sharing your working template.

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