'mfn_get_authors' function really slowing down Blog and category pages - can we remove?

Hi,

There is something in the functions.php which seems to be really slowing down any blog page like
or
sometimes ending in a 502

I've tried deleting and re-importing all posts.  I've also tried loading the Be Theme directly without the child theme - no help.  We don't find this problem occurs when we activate any other theme with the same content.

A developer said it looks to be this snipped causing the trouble:
if( ! function_exists( 'mfn_get_authors' ) )
{
        function mfn_get_authors(){

                $authors = get_users();

                if( is_array($authors) ){
                        foreach( $authors as $ka => $author ){
                                $remove = true;
                                if( in_array( 'author', $author->roles ) ) $remove = false;
                                if( in_array( 'editor', $author->roles ) ) $remove = false;
                                if( in_array( 'administrator', $author->roles ) ) $remove = false;
                                if( $remove ) unset( $authors[$ka] );
                        }
                }

                return $authors;
        }
}

We wanted to ask you guys whether or not it is imperative that it's included then I can either remove or cripple the code so that it works.

Please let us know, thanks!

And if you have experienced this problem before and there is anything else we can do, that'd be appreciated as well.  Thanks!

Comments

  • You could possibly do that in the child theme. Edit the functions.php and change this code so it looks like this.
    if( ! function_exists( 'mfn_get_authors' ) )
    {
    function mfn_get_authors(){

    $authors = get_users();

    return $authors;
    }
    }
  • actually the best way is get_users("type=authors");

    I'd make note of this and push update asap.
Sign In or Register to comment.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.