Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Supporter CPT #149

Open
lovestulip opened this issue Nov 18, 2024 · 29 comments
Open

Create Supporter CPT #149

lovestulip opened this issue Nov 18, 2024 · 29 comments
Assignees

Comments

@lovestulip
Copy link

lovestulip commented Nov 18, 2024

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.

@gin0115
Copy link
Collaborator

gin0115 commented Dec 2, 2024

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 :)

@lovestulip
Copy link
Author

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

@ajolo2ky
Copy link
Contributor

ajolo2ky commented Dec 4, 2024

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

@gin0115
Copy link
Collaborator

gin0115 commented Dec 4, 2024

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)

@ajolo2ky
Copy link
Contributor

ajolo2ky commented Dec 4, 2024

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

@gin0115
Copy link
Collaborator

gin0115 commented Dec 4, 2024

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

@gin0115
Copy link
Collaborator

gin0115 commented Dec 5, 2024

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

@gin0115 gin0115 self-assigned this Dec 5, 2024
@gin0115
Copy link
Collaborator

gin0115 commented Dec 12, 2024

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

@lovestulip | @ajolo2ky

@lovestulip
Copy link
Author

@ajolo2ky Can you please confirm?

@ajolo2ky
Copy link
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.

@gin0115
Copy link
Collaborator

gin0115 commented Dec 17, 2024

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

@lovestulip
Copy link
Author

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

@ajolo2ky
Copy link
Contributor

ajolo2ky commented Jan 8, 2025

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,

@gin0115
Copy link
Collaborator

gin0115 commented Jan 9, 2025

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.

@ajolo2ky
Copy link
Contributor

ajolo2ky commented Jan 9, 2025

Yes, we don't want to mess the current permalink structure. Can we remove the individual pages created by this CPT? I think that'd be faster.

@gin0115
Copy link
Collaborator

gin0115 commented Jan 9, 2025

Is the aim for the supporters only to be shown on a single page? if so we can remove the ability for supporters to have a /supporter/joe-bloggs url.

@ajolo2ky
Copy link
Contributor

ajolo2ky commented Jan 9, 2025

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.

@xpurichan
Copy link

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

@gin0115
Copy link
Collaborator

gin0115 commented Jan 14, 2025

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

Will reply for pr162 on there directly

@gin0115
Copy link
Collaborator

gin0115 commented Jan 17, 2025

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/

@gin0115
Copy link
Collaborator

gin0115 commented Jan 21, 2025

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

@lovestulip
Copy link
Author

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

@smaffulli
Copy link
Contributor

smaffulli commented Jan 21, 2025 via email

@gin0115
Copy link
Collaborator

gin0115 commented Jan 22, 2025

@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?

@smaffulli
Copy link
Contributor

smaffulli commented Jan 22, 2025 via email

@gin0115
Copy link
Collaborator

gin0115 commented Jan 22, 2025

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)

@smaffulli
Copy link
Contributor

smaffulli commented Jan 22, 2025 via email

@gin0115
Copy link
Collaborator

gin0115 commented Jan 22, 2025

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.

@smaffulli
Copy link
Contributor

smaffulli commented Jan 22, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants