[Resolved] Blog page layout

Home Forums Support [Resolved] Blog page layout

Home Forums Support Blog page layout

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #662663
    Gian

    Hi,

    I’m switching all my websites to GeneratePress but I have a few issues I’m not able to fix by myself and was hoping for your help.

    First of all, I’d like to have this layout https://www.cambiarevita.eu/blog but in the blog page of the website with GeneratePress Premium installed, I’m not able to hide Google Adsense ads, while in the other website the ads on the blog page are not showing up (both websites use the same plugin to show ads and have the same settings).

    The strange thing is that the ads do not show up in category or archive pages (see this category page for example https://www.viaggiaregratis.eu/compagnie-aeree). Do you know what I should do to hide ads? I also tried the plugin WP Show Posts to display articles but the ads were not hidden.

    Also, I would like to have an h4 instead of h2 tag for the post titles in blog page, category and archives pages, could you please suggest some code or settings in order to achieve this?

    The last thing is the length of the excerpt, is there a way to force it to 25/30 words even if I’m using the read more tag in articles (like in the other website with another theme installed)?

    Thank you in advance for your help!

    #662859
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    1. How are you inserting the ads currently?

    2. The blog post titles are <h2> elements for accessibility reasons. However, if you need to change them, you would need to copy the content.php file and add it to your child theme. Then you’d need to make the change here: https://github.com/tomusborne/generatepress/blob/2.1.4/content.php#L34

    3. Try this function:

    add_filter( 'generate_show_excerpt', function( $show ) {
        if ( is_archive() || is_home() ) {
            return true;
        }
    
        return $show;
    } );
    #662930
    Gian

    Hi Tom,

    1. With this plugin https://wordpress.org/plugins/quick-adsense-reloaded/

    2. If I change the h2 elements in content.php, only the blog post title will change or also titles on archive and category pages?

    3. I’ve added the code inside the Snippets plugin but it says: The snippet has been deactivated due to an error on line 2: syntax error, unexpected ‘{‘

    Thank you in advance!

    #663479
    Tom
    Lead Developer
    Lead Developer

    1. So we’d need to ask the developer if it’s possible to disable the functionality of their plugin within certain conditions.

    2. That will change it on archives and category pages as well.

    3. Sorry about that! I just edit the code above so it should work πŸ™‚

    #663525
    Gian

    Hi Tom, thank you for reply.

    1. The plugin is working well on my other website (cambiarevita.eu/blog) with another theme installed and I can select the “No Ads” option on certain pages, that’s why I can’t figure out why is not working well with GeneratePress.

    2. I will probably use the WP Show Posts plugin then, I don’t like having a child theme πŸ™‚

    3. I put the code in a Snippet and set the excerpt world count to 25 in the Customizer, but it’s not working only on the blog page (it’s working on categories and archives) πŸ™

    #663791
    Tom
    Lead Developer
    Lead Developer

    1. Can you select not to display ads on the blog though? GeneratePress isn’t doing anything special with the blog page – it’s 100% core WordPress.

    3. That’s strange – where are you adding the code?

    #663908
    Gian

    Hi Tom,

    1. I can select not to display ads on categories, archives, tag pages and on each page I have the option to “Hide all Ads on page”, but I think there is some sort of conflict with GeneratePress that override the plugin settings.

    I’m saying this because on this website that I own – cambiarevita.eu/blog – with the same plugin installed and with another theme (soon will be GeneratePress), as you can see ads are not showing up on the blog page.

    3. I put the code using the Code Snippets plugin https://it.wordpress.org/plugins/code-snippets/ and selected “Run Snippet Everywhere”. Any thoughts? It’s seems that the blog page is “ignoring” other settings such as ads, excerpt etc

    4. Also, is it possible to reduce the space between featured image, post title and the beginning of the article?

    5. Is there a way to show the category on the same line of the post date?

    See image https://prnt.sc/koijtm for 4. and .5

    Thank you in advance for your help!

    #664606
    Tom
    Lead Developer
    Lead Developer

    1. While anything is possible, I don’t see how that would be. GeneratePress isn’t doing anything special here. Perhaps ask the theme author if it’s possible to disable the ads on is_home()? Or maybe there’s a filter we can hook into to disable them ourselves?

    3. Try this code instead:

    add_action( 'after_setup_theme', function() {
        add_filter( 'generate_show_excerpt', function( $show ) {
            if ( is_archive() ) {
                return true;
            }
    
            return $show;
        } );
    } );

    4. Adjust the top margin with this CSS:

    .entry-content, .entry-summary, .page-content {
        margin-top: 2em;
    }

    And the featured image margin:

    .post-image-above-header .inside-article .featured-image, .post-image-above-header .inside-article .post-image {
        margin-bottom: 2em;
    }

    5. This should do it: https://generatepress.com/forums/topic/blog-categories-below-date/#post-472870

    #664723
    Gian

    1. Ok, I’ll ask.

    3. Not working on the blog page πŸ™

    4. Not working πŸ™

    5. Working, thank you!

    #664918
    Tom
    Lead Developer
    Lead Developer

    3. I’ll play with this and will get back to you.

    4. Where did you add the CSS? I’m not seeing it anywhere.

    #664942
    Gian

    3. Ok, thank you.

    4. Added again now in the Simple CSS plugin.

    #665479
    Tom
    Lead Developer
    Lead Developer

    3. I just edited the function above – it should work now: https://generatepress.com/forums/topic/blog-page-layout/#post-662859

    4. Make sure you actually change the margin in the CSS I gave you. 2em is default, but you can change it to anything, including something like 5px.

    #665500
    Gian

    Hi Tom!

    3. Working now and also the ads on the blog page disappeared!

    4. Sorry about that, edited and now working as well.

    Thank you!

    #665632
    Tom
    Lead Developer
    Lead Developer

    You’re welcome πŸ™‚

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