I've seen a lot of similar questions to this one, but not exactly this question. When one is directed to https://www.example.com/civicrm/contribute/transact/?_qf_Confirm_display=true&qfKey=CRMContributeControllerContributionabclongstringherexyz, the page title in the shows as "CIVICRM". I tried to change this via functions.php with the_title hook, but it replaces every title in the menu as well. Any suggestions appreciated.
-
doesn't it shows Contribution page title?– Pradeep NayakCommented Nov 8, 2022 at 19:52
-
Can you try to replicate this (the title showing as CIVICRM instead of the public page title) on wpmaster: wpmaster.demo.civicrm.org– Lars SGCommented Nov 9, 2022 at 0:59
-
I just tried and it seems to work as expected both with and without a specified public page title.– Lars SGCommented Nov 9, 2022 at 0:59
-
@PradeepNayak - the Contribution page does, but we are using the "Use a confirmation page" option, and the confirmation page (which appears after one clicks "Review Your Contribution" displays "CIVICRM" as the page title.– Scott HCommented Nov 9, 2022 at 15:10
-
@LarsSG - can you tell me WHERE you are able to specify / not specify a title for the Review Your Contribution (Confirmation) page?– Scott HCommented Nov 9, 2022 at 15:10
1 Answer
Short of figuring out where the "CiviCRM" page title was coming from in the auto-generated output, I was able to set the name of the Contribution > Confirmation page by adding a script in the footer (using the "wp_footer" hook in the child theme's functions.php) that checks the URL for a query string value associated with the Confirmation page ("_qf_Confirm_display") when the page ID is that of the Contribute / Donate page, and if that value is "true," overwrites the h1 and the document title with what I want:
add_action( 'wp_footer', 'change_donate_conf_title');
function change_donate_conf_title() {
if (is_page(10911)) {
$checkConf = $_GET['_qf_Confirm_display'];
if ($checkConf === 'true') {
echo "<script type='text/javascript'>
document.title = 'Review Your Contribution';
document.querySelector('h1').innerHTML = 'Review Your Contribution';
</script>";
}
}
}
I hope this helps someone else down the road.
-
I accepted my own answer here because it allowed me to change the name of ONLY the confirmation page. However, it is worth noting that Christian's last comment on the OP was valid; the "Shortcode Display Mode" was set to "Legacy Base Page Mode." Changing that should have passed the Public Name from the Form settings to the Confirmation page.– Scott HCommented Nov 11, 2022 at 15:12