Home / Archive / MemberPress: Add Membership Titles To the Top of Registration Pages
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: Add Membership Titles To the Top of Registration Pages

This code snippet will add a membership title to each MemberPress membership registration page. Titles will be positioned at the top of registration pages.

Code Preview
php
<?php
add_action('wp_footer', function() {
  if (is_singular('memberpressproduct')) {
    echo '<h1 class="mpTitle">' . get_the_title() . '</h1>';
?>
  <script>
    document.addEventListener('DOMContentLoaded', function() {
    // Select the <h1> element and the <main> element
      var titleElement = document.querySelector('.mpTitle');
      var mainElement = document.querySelector('main#primary');
      // Move the <h1> element to the end of the <main> content
      if (titleElement && mainElement) {
        mainElement.insertBefore(titleElement, mainElement.firstChild);
      }
  });
  </script>
<?php
}
});

Comments

Add a Comment