• Resolved rvc2

    (@rvconnelly)


    I’m not a php developer. I can handle html and css and my goal is to become proficient with php and javascript but right now I dabble with the latter two. In this case, I added some code to functions.php to create a customized Author Info Box below every post. Here’s the code at GIST.

    The site involves an association of 19 people – all of whom will be writing blog articles – with only a couple of them (with limited WP knowledge) performing the task of actually posting the articles. So, it works out well that Author Info Box automatically pulls the author’s display_name into the info box at the end of each post (single.php).

    The problem is that the info box is also showing on a custom post type of single-professional.php, which provides a profile/description of each author. I only want the author info box to show on single.php. I’ve temporarily used CSS (display:none) to keep it from displaying on the wrong pages but I need to come up with a better solution.

    I’m looking for the appropriate code to show the info box below all blog articles (single.php) but NOT show it on custom post pages like single-professional.php because they are author profiles, not articles.

    Here’s an example page from the site where the info box shows correctly (scroll down to the end of the article) and here’s an example page where I do NOT want it to show. (Again, it’s currently not showing because I’ve removed it with css; you can find it with a browser inspection tool. I need to get rid of it completely.)

    Any assistance with what the correct code needs to be to show the author info box only on single.php and NOT single-professional.php would be greatly appreciated. Thanks.

    • This topic was modified 7 years, 1 month ago by rvc2.
    • This topic was modified 7 years, 1 month ago by rvc2.
    • This topic was modified 7 years, 1 month ago by bdbrown.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Give this a try:

    /* hide author bio */
    .author_bio_section {
        display: none;
    }
    /* display author bio on single posts */
    .single-post .author_bio_section {
        display: block;
    }
    Thread Starter rvc2

    (@rvconnelly)

    Thanks for your reply. Sorry if I wasn’t clear. I’m actually looking for the proper “php code” to keep the Author Info Box code completely off the custom post type pages. Right now I’m using the following css:

    .single-professional p.author_info {
    	display: none;	
    }

    It only hides it, of course, so its a temporary solution. I want to keep the php code that creates the author info box off the custom post type pages completely. Those pages are already starting to rank for the hidden keywords. That’s a problem, of course. I want to avoid any penalties / ranking demotions from search engines. Would you be able to provide any PHP code assistance to achieve the objective? Thanks. -Bob

    • This reply was modified 7 years, 1 month ago by rvc2.

    In that case I’d probably copy single.php to a child theme, take your code out of functions.php and add it to the child theme template.

    Moderator bcworkz

    (@bcworkz)

    bdbrown makes a perfectly reasonable suggestion, but for the sake of variety in accomplishing the same thing, you could conditionally define $author_details based on the value of $post->post_type. If it’s equivalent to ‘professional’ then $author_details = ''; // 2 single quotes, not one double

    I’ll leave the complete code up to you as an exercise if you’re interested 🙂

    Thread Starter rvc2

    (@rvconnelly)

    Thanks very much for the solutions! As soon as I read them, both remedies conceptually made sense to me. Successful implementation has been a bit of a challenge though. After spending a few hours and running into problems, I decided to go with a temporary fix; a deviation of bdbrown’s suggestion. I simply moved the code from functions.php into single.php. Thankfully, that worked and will address my seo/ranking concern. The profile pages in question (custom post type) had already started dropping in the serps, caused by what I believe was the invisible text.

    I inherited maintenance of this site and have learned that its really old or simply built without regard to WP standards. In any case, this theme will not be receiving any updates from the original author so over-writing code will not be an issue. I will re-attempt the more appropriate solutions you both recommended when I have more time and without the pressure of those pages dropping in rank. Thanks again!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to Remove Author Info Box from custom post types’ is closed to new replies.