- This topic has 13 replies, 2 voices, and was last updated 5 years, 7 months ago by Tom.
-
AuthorPosts
-
August 28, 2018 at 2:06 pm #662663Gian
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!
August 28, 2018 at 7:14 pm #662859TomLead DeveloperLead DeveloperHi 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 thecontent.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#L343. Try this function:
add_filter( 'generate_show_excerpt', function( $show ) { if ( is_archive() || is_home() ) { return true; } return $show; } );
August 28, 2018 at 10:45 pm #662930GianHi 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!
August 29, 2018 at 9:17 am #663479TomLead DeveloperLead Developer1. 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 π
August 29, 2018 at 9:54 am #663525GianHi 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) π
August 29, 2018 at 6:51 pm #663791TomLead DeveloperLead Developer1. 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?
August 29, 2018 at 10:49 pm #663908GianHi 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!
August 30, 2018 at 10:57 am #664606TomLead DeveloperLead Developer1. 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
August 30, 2018 at 1:30 pm #664723Gian1. Ok, I’ll ask.
3. Not working on the blog page π
4. Not working π
5. Working, thank you!
August 30, 2018 at 10:05 pm #664918TomLead DeveloperLead Developer3. I’ll play with this and will get back to you.
4. Where did you add the CSS? I’m not seeing it anywhere.
August 30, 2018 at 11:36 pm #664942Gian3. Ok, thank you.
4. Added again now in the Simple CSS plugin.
August 31, 2018 at 11:11 am #665479TomLead DeveloperLead Developer3. 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 like5px
.August 31, 2018 at 11:56 am #665500GianHi 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!
August 31, 2018 at 5:18 pm #665632TomLead DeveloperLead DeveloperYou’re welcome π
-
AuthorPosts
- You must be logged in to reply to this topic.