Posted: March 19, 2014 at 8:49 am
|
Hi, Some of my events require approval before being able to complete/pay for the event. So, I’d like to change the button text of “Register Now” to “Apply Now”. Is it possible to update the button text on a per-event basis? WP 3.8 |
EDIT: use Dean’s code samples instead: http://staging.eventespresso.com/topic/change-register-now-button-text-per-event/#post-87608 Hello, I have an idea that may work. The page that you linked to has this html for the register now button: <input id="ticket-selector-submit-2223-btn" class="ticket-selector-submit-btn" type="submit" value="Register Now"> I found this on Stack Exchange: http://wordpress.stackexchange.com/questions/6201/how-to-use-str-replace-outside-the-loop Since the ids for the buttons are unique per event, you should be able to selectively apply the str_replace and you’ll want to change the value. Something like this: function adjust_button_event_2223($content) { str_replace('<input id="ticket-selector-submit-2223-btn" class="ticket-selector-submit-btn" type="submit" value="Register Now">','<input id="ticket-selector-submit-2223-btn" class="ticket-selector-submit-btn" type="submit" value="Apply Now">',$content); return $content; } add_filter('the_content','adjust_button_event_2223'); If the above works for one event, then you could duplicate a similar function for another event. You would need to update the number 2223 to the number that is shown in the html for the event that you are trying to target. —
|
|
|
Hi Lorenzo, Thanks for your help. I tried adding that function to my theme’s function.php file, but it did not work. Any other suggestions? I tested on the staging site here: https://fsx.staging.wpengine.com/register-now/presenting-company-registration/ Thanks, Alex |
EDIT: use Dean’s code samples instead: http://staging.eventespresso.com/topic/change-register-now-button-text-per-event/#post-87608 Hi Alex, this will work: function event_button_override_2223($phrase) { if (is_single('2223')) { $phrase = str_replace('Register Now', 'Apply Now', $phrase); return $phrase; } } add_filter('the_content', 'event_button_override_2223', 200); It does a check to see if you are viewing a certain event page and then runs the find and replace command. Double-check the ID for your event and update it in the function above. It should go into your theme’s functions.php for or a custom plugin. —
|
|
|
Lorenzo, I tried that, but it actual hid all page content – no text or ticket select was shown. I double checked my ID and confirmed as I am using the shortcode: THanks, |
Hi, I’ve amended Lorenzo’s code a little bit. function event_button_override_2223($phrase) { $post = get_the_id(); if ($post == 2223 ) { $phrase = str_replace('Register Now', 'Apply Now', $phrase); return $phrase; } else { return $phrase; } } add_filter('the_content', 'event_button_override_2223', 200); This will work on single and archive (event list) pages. For more events, you would need to duplicate the if section: if ($post == 2223 ) { $phrase = str_replace('Register Now', 'Apply Now', $phrase); return $phrase; } and add the new ID’s. E.g. function event_button_override_2223($phrase) { $post = get_the_id(); if ($post == 2223 ) { $phrase = str_replace('Register Now', 'Apply Now', $phrase); return $phrase; } if ($post == 2224 ) { $phrase = str_replace('Register Now', 'Apply Now', $phrase); return $phrase; } if ($post == 2225 ) { $phrase = str_replace('Register Now', 'Apply Now', $phrase); return $phrase; } if ($post == 2226 ) { $phrase = str_replace('Register Now', 'Apply Now', $phrase); return $phrase; } else { return $phrase; } } |
|
|
Hi Dean, It works on single and archive (event list) pages. But not with the shortcode. Is it possible to apply this to the button shown via the event shortcode? Thanks, Alex |
|
Hi Alex, You could try adding another where $ID is the post ID of the page that has the shortcode on it. |
|
Thanks for the input Josh. Could you be specific on where to add that snippet and how the final function would look like? |
Hello, This can go into a custom WP plugin that you create (http://justintadlock.com/archives/2011/02/02/creating-a-custom-functions-plugin-for-end-users) Alternatively, you can add it to your theme’s functions.php file. This will be in this location: The post id for a page appears at the end of the URL when you are viewing the WordPress page in the admin. In this example: example.com/wp-admin/post.php?post=116&action=edit …the post id for the page will be 116 Now that you have that you can move that information into the example function. The following would run the function ONLY on a page with an id of 116: function event_button_override_page_116($phrase) { $post = get_the_id(); if ($post == 116 ) { $phrase = str_replace('Register Now', 'Apply Now', $phrase); return $phrase; } else { return $phrase; } } add_filter('the_content', 'event_button_override_page_116', 200); Does that help? — |
|
|
Yes, that helps. I just was not sure where to place the snippet within the function that Josh recommended trying. |
|
Just tried that, and it worked. THanks everyone for your help. |
Thanks for letting us know, have a great weekend! — |
|
The support post ‘Change "Register Now" button text per event’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.