Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Astra Theme - Add 'Apply Now` button in the Header conditionally with a link to page with a form to apply.
<?php // don't copy this line in your file.
// Condition to check if this page requires `Apply Now` button.
if ( 1481 === get_the_id() ) {
your_prefix_setup_header_button_apply_now();
}
/**
* Setup filters for changing the values in the Astra Settings.
*/
function your_prefix_setup_header_button_apply_now() {
add_filter( 'astra_get_option_header-main-rt-section', 'your_prefix_header_rt_text_html' );
add_filter( 'astra_get_option_header-main-rt-section-html', 'your_prefix_header_rt_text_html_content' );
}
/**
* Returns the item key for text-html area in the custom menu item.
*
* @return String option key for text-html area in the custom menu item.
*/
function your_prefix_header_rt_text_html() {
return 'text-html';
}
/**
* Returns markup required for the `Apply Now` button.
*
* This can be any HTML markup of your choice.
* Here 1792 is the ID for the page where the `Apply Now` form is.
*
* @return String HTML markup for the `Apply Now` button.
*/
function your_prefix_header_rt_text_html_content() {
return
'<span class="top-nav-book-cta">
<a href="'. get_permalink( 1702 ) .'">Apply Now</a>
</span>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.