• kaskarino

    (@kaskarino)


    I am trying to customize my new theme (SimpleMag), but i am having a serious problem.

    I want to remove the author box from a specific author. Author boxes should appear for all author except 1.

    Does anyone know any trick to do it?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    You mean the author box when an author’s posts are listed on the front end? Not the author meta box on the post edit screen?

    It depends on how your theme displays the box to start with. We can’t know this with commercial themes. Anyway, you would wrap that display part in a conditional that might look something like this:

    global $authordata;
    if ( 1 != $authordata->ID ) {
       // the theme's author box output code
    }

    This would be typically the author.php template, but theme’s vary in their use of templates. It also assumes the first post is retrieved to determine the author and set the $authordata global before rewinding back to the beginning. Again, themes vary how this is done.

    My understanding of ThemeForest themes is they are difficult to safely customize because they are implemented as child themes of a generic core theme. Being already a child theme takes away your opportunity to make your own child theme that would protect your customizations from theme updates.

    (if you did mean the edit screen metabox, conditionally enqueue some CSS to hide it when the current user ID == 1)

    Thread Starter kaskarino

    (@kaskarino)

    Thanks bcworkz for your reply.

    I mean the author bio under every post.

    I don’t know much coding, but I think that a conditional function may help.

    Here is a piece of code of single.php

    // Show/Hide author box
                        if ( $ti_option['single_author'] == 1 ) {
                            get_template_part( 'inc/author', 'box' );
                        }

    Any trick to hide author box for a specific author?

    If you want, I can show you all single.php and author-box.php code.

    Moderator bcworkz

    (@bcworkz)

    It’s not a good idea to publish commercial code. You apparently have found the correct part to play with anyway. If it’s in the “Loop”, this should work:

    global $authordata;
    if ( 1 != $authordata->ID ) {
       get_template_part( 'inc/author', 'box' );
    }

    This does disable the single author option feature. If that’s important, the two can be combined, but I’m not sure if AND or OR logic is the one to apply.

    If it is not currently in the loop, I see no harm in moving it there on single.php. Keep in mind I’ve no idea what the single.php code looks like, so some adjustment may be necessary. It wouldn’t matter much what is on author-box.php.

    Thread Starter kaskarino

    (@kaskarino)

    Unfortunately, it didn’t work.

    I don’t know why. Maybe I did something wrong…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Disable author box from specific author’ is closed to new replies.