Archived topic
Overvieuw number of reactions on specific postst
11 replies · Started by Bram on February 21, 2020
Underneathe my header of the postpages, blogpage and my excerpts on the homepage I should like to see the number of reactions on the posts.(and other information like posttitle, date and author.
Therefore I think I have to create a secondary navigation underneath the header and a kind of menu, but this is only thinking.
I should like to see something like these examples:
https://geldkanon.nl/
https://geldkanon.nl/
https://geldkanon.nl/affiliate-marketing-trends/
Kind regards,
Bram
Hi there,
Doesn't our built-in post meta handle most of this? It looks like it would just need to be moved/styled to be full-width/inline on single posts.
Let me know :)
Hi Tom, if you say so I do not doubt about that, but GP is rather new for me and I try to collect all necessary knowledge to grow up in websiteland
Will you please be so kind to help me on the way by giving me more specific details(screenshots) or manualchapters to get what I should like to achieve.
I am beginning to be a fan of GP and ready to learn.
Underneath my header of the postpages, blogpage and my excerpts on the homepage I should like to see the number of reactions on the posts.(and other information like posttitle, date and author.
Therefore I think I have to create a secondary navigation underneath the header and a kind of menu, but this is only thinking.
I should like to see something like these examples:
https://geldkanon.nl/
https://geldkanon.nl/
https://geldkanon.nl/affiliate-marketing-trends/
The reactions part would have to come from a plugin. Are you using one now that adds the reactions functionality to your site?
As for the GP side of things, let's start by moving the post meta below your page hero with a function:
add_action( 'wp', function() {
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
if ( is_single() ) {
add_action( 'generate_after_header', 'generate_post_meta' );
}
} );
Adding PHP: https://docs.generatepress.com/article/adding-php/
Then you'll want to enable things like the post author, date, categories, and tags in Customize > Layout > Blog.
Let me know once you do that and we'll keep going :)
Hi Tom,
First, I am not using a plugin for reactions functionality.
I try to come as close as possible to this lay-out: https://geldkanon.nl/affiliate-marketing-trends/?unapproved=2&moderation-hash=cfc2402d5e48aee7c54891f6d9c073cf#comment-2
It looks like the standard postpage only has one reactionfield: https://rickmoeliker.nl/creativiteit/
Is this standard postpage simple expandable to the functionalities in above mentioned lay-out example?
Second, is it possible to change your below page hero function, to come as close as posible to the lay-out from this example under the header ( https://geldkanon.nl/makkelijk-geld-verdienen/ ) complete with number of reactions and icons?
add_action( 'wp', function() {
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
if ( is_single() ) {
add_action( 'generate_after_header', 'generate_post_meta' );
}
} );
I hope I do not overasking, but I am looking for the best possible solution.
Kind regards,
Bram
Hi there,
It's not simple, unfortunately. You'd need to use a plugin or a custom function to handle the "reactions" functionality.
The code I provided above will move the post meta (author, date etc..) under the page hero by default. So if you add a page hero, then use the code I provided, you'll have the basic HTML ready to achieve the layout you're after.
Once you do that, let me know where I can see it and I can help with the CSS :)
Hi Tom, thanks for your kind reply.
First:
I am rather satisfied about the simple standard WP reaction functionality, but beside the reactionfied I am missing three fields namely:
1) Naam* (required)
2) Emailadres* (required)
3) Website
These fields are standard in WP, I thought(in settings Discussion I have placed the check marks anyway)
Are these fields disabled in Generatepress? And is it possible to add them again? (I did my best, but I could not find a simple way to add them with CSS or php)
Second:
I have add your code to page hero ( https://rickmoeliker.nl/creativiteit/ ). Please help me with CSS to the layout I am after ( https://rickmoeliker.nl/creativiteit/ )
Kind regards,
Bram
Ahh, the comments functionality - you can definitely add that.
Looking at your example and the HTML we add by default, it won't be as easy as I'd hoped.
So first, remove the function I shared above. Then, let's built a custom HTML element with the data you want:
add_action( 'generate_after_header', function() {
?>
<div class="after-header-entry-meta">
<div class="grid-container grid-parent">
<div class="entry-meta-left">
<div class="entry-meta-categories">
<?php generate_do_post_meta_item( 'categories' ); ?>
</div>
<div class="entry-meta-date">
<?php generate_do_post_meta_item( 'date' ); ?>
</div>
</div>
<div class="entry-meta-right">
<div class="entry-meta-author">
<?php generate_do_post_meta_item( 'author' ); ?>
</div>
<div class="entry-meta-comments">
<?php generate_do_post_meta_item( 'comments-link' ); ?>
</div>
</div>
</div>
</div>
<?php
} );
add_action( 'wp', function() {
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
} );
Once you add that let me know and I can build the CSS for it :)
Hi Tom, thanks for your reply.
1) Once you add that let me know and I can build the CSS for it 🙂
I did ( https://rickmoeliker.nl/creativiteit/ )
2) Ahh, the comments functionality – you can definitely add that.
As I described above, but how can I do that?
Kind regards,
Bram
Add this CSS:
.after-header-entry-meta {
background: #efefef;
padding: 20px;
}
.after-header-entry-meta .grid-container {
display: flex;
}
.entry-meta-right {
margin-left: auto;
display: flex;
}
.entry-meta-left {
display: flex;
}
.entry-meta-left > div {
margin-right: 15px;
}
.entry-meta-right > div {
margin-left: 15px;
}
To add comments, make sure the "Comments" feature is enabled in Customize > Layout > Blog.
Hi Tom, Thanks very, very much, you've made me really happy with your CSS work. Great!!
Now this last part:
To add comments, make sure the “Comments” feature is enabled in Customize > Layout > Blog.
I'm not sure that you understand what I mean.
In the comment functionality there seems to be only one field. The commentfield. https://rickmoeliker.nl/creativiteit/
I should like to add three missing fields namely:
1) Naam* (required)
2) Emailadres* (required)
3) Website
As far as I know it is standard in the Wordpres functionality, when you marked these in your settings.
I should be quite happy with this added fields and its functionaliy. I do not prefer an extra plugin.
As little plugins as possible I am going for. To much plugins makes the website slow, so I have heard.
Is this adding possible?
Kind regards,
Bram
Hi there,
Those fields will display if you log-out. Since you're logged in, it doesn't need your name, email etc..
Let me know :)