• Resolved marjolein64

    (@marjolein64)


    On one of my template pages I use this code:

    <?php echo do_shortcode( ' [contact-form-7 id="13223" title="Verzoek wijzigen contactgegevens bestrijders"]' ); ?>

    Since WordPress 6.2 I get this message:

    PHP Deprecated: Functie get_page_by_title is sinds versie 6.2.0 verouderd! Gebruik in plaats daarvan WP_Query. in xxx/wp-includes/functions.php on line 5413

    The contact form is shown correctly.
    Can you please let me know how I can fix this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • It looks like you or the contact form plugin are using an outdated function, ‘get_page_by_title’, which has been deprecated since WordPress version 6.2.0. As a result, you are receiving a PHP Deprecated warning message.

    To resolve this issue, you can update your code by replacing the deprecated function with ‘WP_Query’. The ‘WP_Query’ function is the current method for retrieving pages by title in WordPress. Here’s how you can modify your code:

    To fix the issue, you can modify your code as follows:

    <?php
    $args = array(
        'title' => 'Verzoek wijzigen contactgegevens bestrijders',
        'post_type' => 'page'
    );
    $query = new WP_Query( $args );
    echo do_shortcode( '[contact-form-7 id="13223" title="Verzoek wijzigen contactgegevens bestrijders"]' );
    ?>

    This code will retrieve the page with the title ‘Verzoek wijzigen contactgegevens bestrijders’ and display the contact form using the ‘do_shortcode’ function.

    For further information on WP_Query, you can refer to the official WordPress documentation: https://developer.www.ads-software.com/reference/classes/wp_query/.

    Additionally, since it is related to Contact Form 7, I recommend creating a support topic in the Contact Form 7 support forum here: https://www.ads-software.com/support/plugin/contact-form-7/#new-topic-0. They have a team of experts who can help you with any issues you’re experiencing.

    Thanks!

    Thread Starter marjolein64

    (@marjolein64)

    Thank you so much! You are right, it is related to CF7 because we use an older version because of another issue with the plugin. Thanks again for your support!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘do_shortcode: get_page_by_title deprecated’ is closed to new replies.