1

I try to add a list of project in the builder of DIVI theme.

I have already managed to insert the project_tag list like this :

            <div class="et-pb-option">
            <label for="et_pb_project_tag">Choisir le(s) réalisateur(s): </label>
            <div class="et-pb-option-container">
            <% var et_pb_include_project_tag_temp = typeof et_pb_include_project_tag !== 'undefined' ? et_pb_include_project_tag.split( ',' ) : []; %>
END;

                $tag_array = get_terms( 'project_tag' );
                foreach ( $tag_array as $tag ) {
                    printf( '<label><input type="checkbox" name="et_pb_include_project_tag" value="%1$s"%3$s> %2$s</label><br/>',
                        esc_attr( $tag->term_id ),
                        esc_html( $tag->name ),
                        '<%= _.contains( et_pb_include_project_tag_temp, "' . $tag->term_id . '" ) ? checked="checked" : "" %>'
                    );
                }
echo <<<END

                <p class="description">Sélectionner le réalisateur.</p>
            </div> <!-- .et-pb-option-container -->
        </div> <!-- .et-pb-option -->

But I don't know how to do with parent custom type "project"

Any suggestions?

  • Do you need a list of the taxonomies under your custom post type, or a list of posts from the custom post type – Pieter Goosen Aug 20 '14 at 12:25
  • A list of posts from the custom post type... do you think it is possible ? thanks ! – jojo79 Aug 20 '14 at 13:45
1

You can create a custom query with WP_Query to get all posts from your post type. This is how a basic query will look like, you just need to tweak it to your needs

<?php

// The Query
$the_query = new WP_Query( 'post_type=project&posts_per_page=-1' );

// The Loop
if ( $the_query->have_posts() ) {

    while ( $the_query->have_posts() ) {
        $the_query->the_post();
        echo '<li>' . get_the_title() . '</li>';
    }

}

wp_reset_postdata();
  • Thank you ! But I have just a list of projects, not a checkboxes list ! I will search how to tweak it properly... – jojo79 Aug 20 '14 at 15:18
  • Just change li with something like p – Pieter Goosen Aug 20 '14 at 15:20
  • I understand... What a shame ! ;) Thanks for your answers anyway. – jojo79 Aug 20 '14 at 15:44
  • If my answer was useful, please consider accepting it as a solution. Thank you – Pieter Goosen Sep 8 '14 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.