Skip to content

Create Supporter CPT #149

Closed
Closed

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.

Activity

  1. gin0115 commented on Dec 2, 2024

    @gin0115
    Contributor

    Hey

    This has been added to staging. I have it ready to go into production along with #152

    Also can confirm that just doing the export from ACF/SCF works for the post type and meta fields. Plus the WP export works fine for the post content too (i did this to test on my local)

    If you would like me to importer those too, let me know :)

  2. lovestulip commented on Dec 2, 2024

    @lovestulip
    Author

    @ajolo2ky Can you please review the latest update and let us know how you'd like us to proceed?

  3. ajolo2ky commented on Dec 4, 2024

    @ajolo2ky
    Contributor

    Hi, thanks. Yes, please promote it to production.

    Also, would it be possible in the wp-admin editing of the CPT, to remove the main body block and just show the custom fields?

    image
  4. gin0115 commented on Dec 4, 2024

    @gin0115
    Contributor

    I will get this pushed up now.

    As for the content editor, you can remove that in the ACF Post Type settings
    image
    image

    Do you want me to import the supporters that are present on the staging site? I have got the export file to hand (didn't share as this is a public repo)

  5. ajolo2ky commented on Dec 4, 2024

    @ajolo2ky
    Contributor

    Thanks! Yes, please import the ones that are already there.

  6. gin0115 commented on Dec 4, 2024

    @gin0115
    Contributor

    I will try and hop on the computer and get them imported tonight 🙂

  7. gin0115 commented on Dec 5, 2024

    @gin0115
    Contributor

    Didnt get a chance last night, but have imported them today.

  8. self-assigned this
    on Dec 5, 2024
  9. gin0115 commented on Dec 12, 2024

    @gin0115
    Contributor

    This has all been imported, can we close this out now?

    @lovestulip | @ajolo2ky

  10. lovestulip commented on Dec 12, 2024

    @lovestulip
    Author

    @ajolo2ky Can you please confirm?

  11. ajolo2ky commented on Dec 16, 2024

    @ajolo2ky
    Contributor

    Hi, sorry for the delay. This is worked, but the slug of supporters appears to be /blog/supporter/[supporter], it should be /supporter/[supporter] without /blog. Is that feasible? thanks.

  12. gin0115 commented on Dec 17, 2024

    @gin0115
    Contributor

    I have changed the permalink locally, its all handled in the ACF settings
    image

    It was adding blog/supporter due to the sites main permalink settings
    image

    Do we want the post single to be accessible? As these are all just ACF meta fields, there is no content to render for the supporters.

    We can use the same format as the shortcode supporter item for the post single views
    image

  13. lovestulip commented on Dec 19, 2024

    @lovestulip
    Author

    @ajolo2ky Let us know your thoughts on the above when you can! Thank you so much!

  14. ajolo2ky commented on Jan 8, 2025

    @ajolo2ky
    Contributor

    Hi, sorry for the delay. I'm not finding the advanced settings box you are showing in the screenshot, where should that be inside of ACF?

    Thanks,

  15. gin0115 commented on Jan 9, 2025

    @gin0115
    Contributor

    Hi @ajolo2ky,

    Apologies for not being clearer earlier! The setting you're looking for is located under Settings -> Permalinks. This isn't an ACF-specific setting—it's a general WordPress configuration.

    I haven't made any changes to it since you currently have over 830 posts relying on that permalink structure (sorry for not checking this sooner).

    If we want supporters to have URLs that exclude the /blog/, we might need to make some different changes. As it stands, those URLs for supporters will show a blank page unless we add a template.

  16. 2 remaining items

  17. ajolo2ky commented on Jan 9, 2025

    @ajolo2ky
    Contributor

    If we could have /supporter/ (instead of /blog/supporter), I'd prefer that. Having the unique URI for each supporter may have it's advantages. But if it's too problematic, for the time being I prefer just removing individual pages, just have them in /ai/endorsements and close this issue.

  18. xpurichan commented on Jan 14, 2025

    @xpurichan

    @gin0115 we'd also like to flag a related issue Ariel is experiencing, which is difficulty committing this PR:
    #162

  19. gin0115 commented on Jan 14, 2025

    @gin0115
    Contributor

    Sorry not forgotten about this, im suddenly swamped with lots of issues and struggling getting through them.

    Will reply for pr162 on there directly

  20. gin0115 commented on Jan 17, 2025

    @gin0115
    Contributor

    With this, it can be done using the acf settings

    Image

    ive never used ACF to register post types, so didnt know it has this option.

    This is done now, so links are not prefixed as /blog/supporter, now its just /supporter/

  21. gin0115 commented on Jan 21, 2025

    @gin0115
    Contributor

    #192 has now gone up and I have changed the permalinks (as above). Suspsect we can close this out now.

  22. lovestulip commented on Jan 21, 2025

    @lovestulip
    Author

    @ajolo2ky Please confirm if we can consider this issue resolved. Thanks!

  23. smaffulli commented on Jan 21, 2025

    @smaffulli
    Contributor
  24. gin0115 commented on Jan 22, 2025

    @gin0115
    Contributor

    @smaffulli

    Sorry you are having issues, ive copied the OSAID Endorsement contact form to my local version and im also getting issues on that form locally

    {
        "contact_form_id": 24780,
        "status": "mail_failed",
        "message": "There was an error trying to send your message. Please try again later.",
        "posted_data_hash": "<REMOVED>",
        "into": "<REMOVED>",
        "invalid_fields": []
    }

    I removed the custom code that was uploaded to handle form submissions and i am still getting the same issue (locally)

    {
        "contact_form_id": 24780,
        "status": "mail_failed",
        "message": "There was an error trying to send your message. Please try again later.",
         "posted_data_hash": "<REMOVED>",
        "into": "<REMOVED>",
        "invalid_fields": []
    }

    However it seems the mail was sent

    Image

    Just so im not trying to compare apples to oranges, do you mind telling me what page the form is on?

  25. smaffulli commented on Jan 22, 2025

    @smaffulli
    Contributor
  26. gin0115 commented on Jan 22, 2025

    @gin0115
    Contributor

    Strange, i just submitted several submissions with different browsers and tried with ublock on or off.

    CHROME (Regular)

    Without

    {
        "contact_form_id": 71702,
        "status": "mail_sent",
        "message": "Thank you for your message. It has been sent.",
        "posted_data_hash": "....",
        "into": "#wpcf7....",
        "invalid_fields": []
    }

    With

    {
        "contact_form_id": 71702,
        "status": "mail_sent",
        "message": "Thank you for your message. It has been sent.",
        "posted_data_hash": "....",
        "into": "#wpcf7-...",
        "invalid_fields": []
    }

    FIREFOX (Regular)

    {
        "contact_form_id":71702,
        "status":"mail_sent",
        "message":"Thank you for your message. It has been sent.",
        "posted_data_hash":"....",
        "into":"#wpcf7-....",
        "invalid_fields":[]
    }

    You don't have a pi hole or anything else running which could stop calls, do you?

    (Tests from a linux machine)

  27. smaffulli commented on Jan 22, 2025

    @smaffulli
    Contributor
  28. gin0115 commented on Jan 22, 2025

    @gin0115
    Contributor

    it is a strange one.

    Do you want to open a new ticket for this, as it's not related to the supporter post type.

    I just need to run some errands and I will look around online and see if anyone else is reporting this when I'm back.

  29. smaffulli commented on Jan 22, 2025

    @smaffulli
    Contributor
  30. ajolo2ky commented on Jan 27, 2025

    @ajolo2ky
    Contributor

    Hi team, I'm closing this issue as the CPT part of it is finished and working. I've sent you a separate email to address the issue @smaffulli was flagging, with more in-depth detail of what I'm seeing under the hood.

    Best,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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