Skip to content

Create Supporter CPT #149

@lovestulip

Description

@lovestulip

Description

This request is to replicate the "Supporter" Custom Post Type (CPT) functionality from staging to production.

Ariel has tested the following code on the staging environment:

function display_cpt_supporters() {
    // Override the main query for this specific case
    query_posts(array(
        'post_type' => 'supporter',
        'posts_per_page' => -1,
        'orderby' => 'title',
        'order' => 'ASC'
    ));

    $output = '<div class="cpt-posts-container">';

    if (have_posts()) {
        while (have_posts()) {
            the_post();

            // Fetch ACF fields
            $name = get_field('name');
            $organization = get_field('organization');
            $quote = get_field('quote');
            $link = get_field('link');

            $output .= '<div class="cpt-post">';
            $output .= '<div class="supporter-info">';
            $output .= '<p><strong>' . esc_html($name) . '</strong><br />';

            // Check if the link field exists and is not empty
            if ($link) {
                $output .= '<i><a href="' . esc_url($link) . '" target="_blank">' . esc_html($organization) . '</a></i><br />';
            } else {
                $output .= '<i>' . esc_html($organization) . '</i><br />';
            }

            if ($quote) {
                $output .= '&quot;' . esc_html($quote) . '&quot;';
            }
            $output .= '</div>';
            $output .= '</div>';
        }
        wp_reset_query(); // Reset the query to the original
    } else {
        $output .= '';
    }

    $output .= '</div>';
    return $output;
}
add_shortcode('display_supporters', 'display_cpt_supporters');

Ariel has requested us to move this functionality to production and ensure it is safe to deploy without breaking existing functionality.

Context

See ZD link on the internal dev request.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions