[Support request] Changing the layout of the elements of a post

Home Forums Support [Support request] Changing the layout of the elements of a post

Home Forums Support Changing the layout of the elements of a post

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2037049
    Patrick

    Hello,
    Sorry for the question that you have probably been asked very (too) often.
    How to remove meta information (date, author, category…) in posts of a certain category?
    See in the screenshot the elements to remove.
    https://ndf2.cw56.net/wp-content/uploads/2021/12/2021-12-03-13_43_24-Greenshot.jpg
    Kind regards

    #2037946
    David
    Staff
    Customer Support

    Hi there,

    sorry for the delay, you’re topic slipped through our system.
    Try this PHP snippet:

    add_action( 'wp', function(){
        if ( in_category( 'category_slug' ) ) {
            remove_action( 'generate_after_entry_title','generate_post_meta', 10 );
            remove_action( 'generate_after_entry_content','generate_footer_meta', 10 );
        }
    } );

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    Just update the category_slug to match your requirements.

    #2038294
    Patrick

    Thank you,
    It’s ok for my first steps, I figured it out by myself without writing any code. I went to an article and launched the customization. In this one I found Layout / Blog / Articles and I was able to uncheck what did not suit me.

    Now, I want to understand your proposition:
    Is the add action(){} to put in child theme/functions.php? It’s what I understand from “Adding PHP: https://docs.generatepress.com/article/adding-php/”

    And after ? Just update category_slug ? I go to posts categories and I select the category then “enter”

    #2038444
    Ying
    Staff
    Customer Support

    Hi Patrick,

    1. Yes, copy and paste the code to your child theme’s functions.php file.

    2. Find out what the slug of the specific category is, replace the category_slug with it.

    3. Save your functions.phpfile.

    Let me know if this helps 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.