Site logo

Archived topic

Blog page layout

13 replies · Started by Gianluca on August 28, 2018

Viewing posts 1–14 of 14

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!

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;
} );

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!

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 :)

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) :(

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?

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!

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

1. Ok, I'll ask.

3. Not working on the blog page :(

4. Not working :(

5. Working, thank you!

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.

3. Ok, thank you.

4. Added again now in the Simple CSS plugin.

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!

You're welcome :)

This archived topic is closed to new replies.