Title: PHP 8.1 &#8211; PHP Warning: Undefined variable $network in (&#8230;)
Last modified: January 3, 2023

---

# PHP 8.1 – PHP Warning: Undefined variable $network in (…)

 *  Resolved [subedinfo](https://wordpress.org/support/users/subedinfo/)
 * (@subedinfo)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/php-8-1-php-warning-undefined-variable-network-in/)
 * Hi,
 * After updating to PHP 8.1 we started on the lookout for issues and conflicts.
   One of this issues comes from the RankMath plugin.
 * We have the following block on our `functions.php` theme file:
 *     ```wp-block-code
       /**
        * Allows developers to change the OpenGraph image within theme.
        * The dynamic part of the hook name. $network, is the network slug. Can be facebook or twitter.
        * @param string $attachment_url The image we are about to add.
        */
       add_filter( "rank_math/opengraph/{$network}/image", function( $attachment_url ) {
       	return $attachment_url;
       });
       ```
   
 * And this results in the continued error on the logs:
 *     ```wp-block-code
       [03-Jan-2023 14:47:56 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
       [03-Jan-2023 14:47:56 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
       [03-Jan-2023 14:47:56 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
       [03-Jan-2023 14:47:57 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
       [03-Jan-2023 14:48:15 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
       [03-Jan-2023 14:48:37 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
       [03-Jan-2023 14:49:03 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
       [03-Jan-2023 14:49:04 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
       [03-Jan-2023 14:49:21 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
       [03-Jan-2023 14:49:39 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
       [03-Jan-2023 14:50:02 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
       [03-Jan-2023 14:50:37 UTC] PHP Warning:  Undefined variable $network in /var/www/sites/ver7x1/public_html/production/wp-content/themes/hello-child/functions.php on line 43
       ```
   
 * Thank you.

Viewing 1 replies (of 1 total)

 *  Plugin Support [Rank Math Support](https://wordpress.org/support/users/rankmathteam/)
 * (@rankmathteam)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/php-8-1-php-warning-undefined-variable-network-in/#post-16343840)
 * Hello [@subedinfo](https://wordpress.org/support/users/subedinfo/),
 * Thank you for contacting the support, and sorry for any inconvenience that might
   have been caused due to that.
 * The implementation of your filter code is incorrect.
 * You need to ensure that you have provided a value for the variable **$network**
   and it could be either “facebook” or “twitter”
 * Here’s an example for a correct hook:
 * “rank_math/opengraph/facebook/image”
 * or
 * “rank_math/opengraph/twitter/image”
 * Hope that helps.

Viewing 1 replies (of 1 total)

The topic ‘PHP 8.1 – PHP Warning: Undefined variable $network in (…)’ is closed 
to new replies.

 * ![](https://ps.w.org/seo-by-rank-math/assets/icon.svg?rev=3438330)
 * [Rank Math SEO – AI SEO Tools to Dominate SEO Rankings](https://wordpress.org/plugins/seo-by-rank-math/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/seo-by-rank-math/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/seo-by-rank-math/)
 * [Active Topics](https://wordpress.org/support/plugin/seo-by-rank-math/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/seo-by-rank-math/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/seo-by-rank-math/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Rank Math Support](https://wordpress.org/support/users/rankmathteam/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/php-8-1-php-warning-undefined-variable-network-in/#post-16343840)
 * Status: resolved