views of the post only logged

Posted in: Newspaper
Post count: 71

Hello,
is it possible with a js or a bit of code (or simply with CSS), hide the views of the post to those who are not logged in?

Post count: 35449

Hi,
I think that this can be done with some extra code in the theme files. I think that it can be used this condition -> https://developer.wordpress.org/reference/functions/is_user_logged_in/
Thank you!

Post count: 71

Hello Calin,
thanks for your reply. I’m not very familiar with the code. I ask you the courtesy if you can help me. Thank you

Post count: 35449

Hi,
I do not have a code to provide, but I will try my best to find one and get back to you with it!
Thank you!

Post count: 71

Ok thank you, I wait and thank you.

Post count: 35449

Hello,
You can try this custom code from here, this code need to be set in functions.ph, so I recommend to use a child theme and set the code in the functions.ph file from the child theme.
I hope this will help you!

Post count: 71

Hello,
thanks for your feedback.
I added the code you pointed out to me at the end of the functions.php file, but it gives me error in WordPress… maybe something is missing?

Post count: 35449

Hello,
I just test it on my install and for me is working. (Newspaper v11.5.1)
Can you please let me know the path and some screenshots you set the code?
Thank you!

Post count: 71

Hi, I pasted your code at the end of the functions.php file.

That’s it 🙁

Post count: 35449

Maybe you set it in the wrong functions.php file
I just tested again and for me is working, I also test it in child theme -> https://i.imgur.com/RCDPZC3.png -> https://i.imgur.com/3tQEDB4.png

Viewing 10 posts - 1 through 10 (of 10 total)
The forum ‘Newspaper’ is closed to new topics and replies.