Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter codypersinger

    (@codypersinger)

    !!!! I believe I’ve just solved my own problem, and I feel like a complete idiot!

    I removed the get_posts method from my repeater template and the shortcode seems to be working beautifully now. I think I completely misunderstood how ALM works in regards to the repeater template. ALM is making its own calls to grab posts, I just need to provide it the specifics. Instead, I was trying to write the call to grab posts. Thanks so much for your assistance in this dcooney, I doubt I would have ever figured it out if I hadn’t been tinkering during this debug session. You rock!

    Thread Starter codypersinger

    (@codypersinger)

    First I’ll note that I’m using the shortcode like so, not sure if it makes a difference:

    <?php echo do_shortcode('[ajax_load_more posts_per_page="1" button_label="View More" destroy_after="2" scroll="false"]'); ?>

    All of the parameters you see there work perfectly. However, if I try this:

    <?php echo do_shortcode('[ajax_load_more posts_per_page="1" button_label="View More" destroy_after="2" scroll="false" post_type="mag_show_post"]'); ?>

    or this:

    <?php echo do_shortcode('[ajax_load_more posts_per_page="1" button_label="View More" destroy_after="2" scroll="false" meta_key="season_number" meta_value="2"]'); ?>

    Using either of those shortcodes, ALM will display only posts with the post_type of ‘post’. It will not display posts with the specified post_type or the specified meta_key.

    Thread Starter codypersinger

    (@codypersinger)

    I am unable to pass the post_type via the shortcode, but if I pass it into the get_posts() method in the repeater template it does work. The same is true for meta_key and meta_value.

    This is the code I am using in the repeater template:

    <span>
    <?php global $post;
    $recentposts = get_posts(array(
    	'post_type' => 'mag_show_post',
    	'meta_key' => 'season_number'
    ));
    foreach ($recentposts as $post) : setup_postdata($post);
    $post_season_number = get_field('season_number'); ?>
        //display each post here
    <?php endforeach; wp_reset_postdata(); unset($post); ?>
    </span>

    I’m not doing anything with $post_season_number in the repeater template because I wasn’t able to provide it access to the $page_season_number. This wouldn’t be a problem if I could pass $page_season_number through the shortcode, but unfortunately that’s been an issue as well. Somehow I need to provide both the $page_season_number and the $post_season_number in the same context so that I can compare the two.

    Thread Starter codypersinger

    (@codypersinger)

    Unfortunately the page currently exists only in my local environment, and I believe client confidentiality may prohibit me from sharing even if it were not. I do realize this may make it very difficult or impossible to debug and apologize for the inconvenience. I would be happy to share any further details or code required.

    Thread Starter codypersinger

    (@codypersinger)

    Sorry for the late reply, I did not have access to my dev environment last night. I set up the WP_Query on the “show-template.php” page. I used the following:

    <?php $wp_query = new WP_Query (array (
          'post_type' => 'mag_show_post',
          'post_per_page' => -1,
          'meta_query' => array(
               array(
                   'key' => 'season_number',
                   'value' => $page_season_number,
                   'compare' => '='
              )
         )
    )); ?>

    The query returned the expected posts which match the season_number, so it seems to work well.

    Thread Starter codypersinger

    (@codypersinger)

    Excellent, thanks for your clarification. I will report back as quickly as possible.

    Thread Starter codypersinger

    (@codypersinger)

    I would like to add that during my testing of the ALM shortcode, I was not able to select by post_type either. I am able to get post_type to work when I pass it into the repeater template:

    get_posts('post_type=post')

    Other ALM shortcode works fine, such as destroy_after, scroll, and button_label – but post_type, meta_key, and meta_value do not seem to work in my shortcode.

    Thread Starter codypersinger

    (@codypersinger)

    Hi dcooney, thanks for your speedy reply. I am somewhat familiar with the meta_query – or at least know where to find the documentation on it. How are you suggesting I use it? My apologies for not understanding fully – I have been working on this issue for many hours today and my brain is starting to get a little fried!

    I’d be more than happy to try whatever you recommend. Thanks very much for your effort in troubleshooting, and for the excellent plugin.

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