• Resolved dhdesign1356

    (@dhdesign1356)


    I started using pods for the first time, and while I was excited, I’m having a hard time getting the loop to work. The idea is to display a custom post type created called Home Section with which I’ve created custom fields. As of right now, the variable isn’t showing as existing but this is the closest I’ve come to having anything function using the pod loop.

    <?php

    $mypod = pods(‘home_section’);

    if( $mypod->exists() ){

    $title = $mypod->display(‘title’);
    echo $title;

    }

    else {

    echo ‘This is alll wrong!’;
    }

    ?>

    The good news is, I’m at least getting the else on my if/else loop. I’ve tried many different strategies to call home_section and nothing has worked. Any suggestions would be helpful. I’ve tried calling an array and running ->find() on the array, I’ve tried fetch(), I’ve tried $mypod = pods(‘home_section’, get_the_ID()), but nothing is working unless I run a wp_query loop setting my custom post type in an array. That works great but I don’t access to the full functionality that pods has to offer. I appreciate any and all help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter dhdesign1356

    (@dhdesign1356)

    Looks like the issue wasn’t with my array, but with my using the get_template_part(‘content’, ‘section’); within my loop. I removed it after switching up my loop to include an array, find(), and while(); Now, everything is working.

    <!–/* Start the Loop */–>
    <?php

    $mypod = pods(‘home_section’);
    $params = array(
    ‘limit’ => -1
    );

    $mypod->find($params);

    while ($mypod->fetch()) :
    ?>

    <?php

    $pic = $mypod->field(‘section_background_image’);
    $pic = pods_image_url($pic, $size = ‘full’, $default = 0, $force = false);
    $title = $mypod->display(‘title’);

    ?>
    <style>

    section.section-bkgd {

    background: url(“<?php echo $pic; ?>”) fixed;
    -webkit-box-shadow: inset 0 0 50px rgba(0,0,0,.5);
    -moz-box-shadow: inset 0 0 50px rgba(0,0,0,.5);
    box-shadow: inset 0 0 50px rgba(0,0,0,.5);
    height: 500px;
    }

    </style>

    <section class=”sol-homecontent-style section-bkgd”>
    <div class=”sol-home-section”>

    <h1><?php echo esc_html($title); ?></h1>

    </div><!– .entry-content –>
    </section>

    <?php

    endwhile;
    ?>

    Plugin Contributor Jim True

    (@jimtrue)

    Glad you figured it out.

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

The topic ‘pod loop not pulling custom post type’ is closed to new replies.