-
AuthorPosts
-
August 22, 2018 at 12:09 pm #1000254
Hi, as I have restricted content for logged in users I encountered the problem that private posts are not shown to users when their categories are assigned to e.g. “magazine” or “masonry”. But this is vital for my intranet-plans.
Private posts and pages are shown when posted individually but not when used in Enfold’s “design-elements”.
I guess this is a known problem but any help or code snipped for functions.php or the like are highly appreciated.
I have installed a dev-installation and will provide the link as private content.August 22, 2018 at 2:40 pm #1000359Hey jobalzer,
Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?
Are you using some plugin to restrict access?
Best regards,
VictoriaAugust 22, 2018 at 6:47 pm #1000468This reply has been marked as private.August 23, 2018 at 10:02 am #1000644Any tipps how I can proceed?
August 23, 2018 at 9:03 pm #1000954Hi,
That seems to be an issue with the plugin you are using to lock things down, have you tried to contact the plugin developer?
Best regards,
BasilisAugust 25, 2018 at 12:50 pm #1001624No, it has nothing to do with the Plugin. But do you recommend another way to let private content be shown in magazine or masonry in order to restrict content to user roles and which works with enfold?
August 26, 2018 at 8:20 am #1001820Hi,
You can use this code to include private posts in magazine and masonry elements:
add_filter('avia_masonry_entries_query', 'avia_custom_query_extension', 10, 2); add_filter('avf_magazine_entries_query', 'avia_custom_query_extension', 10, 2); add_filter('avia_blog_post_query', 'avia_custom_query_extension', 10, 2); function avia_custom_query_extension( $query, $params ) { $query['post_status'] = array('publish','private'); return $query; }
Please add this code to the child theme functions.php. If necessary you can also add another post status to the query (i.e. draft or pending, see https://codex.wordpress.org/Class_Reference/WP_Query#Status_Parameters for more information).
Best regards,
DudeAugust 26, 2018 at 10:39 am #1001833Tx, will try!
August 26, 2018 at 10:56 am #1001836Hi,
Ok, I’ll leave this thread open :)
Best regards,
DudeAugust 29, 2018 at 9:37 pm #1003269Sorry for the delay.
The functions.php-code does not work.
Please have a look at the WP-installation I mentioned above. The standard-WP-blog is showing all entries, but the magazine and the masonry don’t.I entered the functions.php-code you gave me via Design -> Editor -> functions.php
Please have a look and feel free to change things, it’s only a system for testing purposes.
Thanks in advance!
August 30, 2018 at 5:15 pm #1003722Hi,
I fixed it now. Tbh I don’t think this is a theme bug however I found the culprit. We use the get_terms() function which excludes empty categories (categories without assigned posts) by default. WordPress does not count private posts to the total number of assigned posts of a category. Because there were no other posts assigned to the “private posts” category wordpress excludes this category from the get_terms() query and the side effect was that our magazine and masonry template didn’t show this category.
I added
array('hide_empty'=>true)
to all occurrences of get_terms() in config-templatebuilder/avia-shortcodes/av-helper-masonry.php and config-templatebuilder/avia-shortcodes/magazine/magazine.php. We’ll probably include another filter with the next update which will enable you to set the hide_empty value to true.
Kind regards,
DudeAugust 30, 2018 at 9:26 pm #1003808Thanks for helping but now it shows the posts even to not-logged-in visitors so public, but the private posts should only be seen by logged-in users.
Kind regards,
jobalzerAugust 31, 2018 at 7:56 am #1003949Hey!
Sry I thought you want to show private posts to all users. You can use this code instead to show posts only to logged in users:
add_filter('avia_masonry_entries_query', 'avia_custom_query_extension', 10, 2); add_filter('avf_magazine_entries_query', 'avia_custom_query_extension', 10, 2); add_filter('avia_blog_post_query', 'avia_custom_query_extension', 10, 2); function avia_custom_query_extension( $query, $params ) { if(is_user_logged_in()) $query['post_status'] = array('publish','private'); return $query; }
Cheers!
PeterAugust 31, 2018 at 9:51 am #1003983Hi Dude,
thanks for your help. But still it does not work satisfiying.
When logged out everything seems to work perfectly. When logged in private posts are missing.Would you please have a look on the page?
Thanks.
(The only element that works flawlessly in any case is the WP-standard-blog – last element on the page. So it actually might be an enfold-issue which I urgently would need to get fixed.)- This reply was modified 6 years, 2 months ago by jobalzer. Reason: forgot to mention the working wp-standard-blog
August 31, 2018 at 10:08 am #1003993Hey!
Please check it again – it should work now.
Best regards,
PeterAugust 31, 2018 at 10:39 am #1004011Thanks, it seems to work now.
Can you pls tell me what you did, so I can apply the fix to my main site and current project?September 1, 2018 at 10:23 am #1004297Hey!
I replaced the code I gave you before with this one:
add_filter('avia_masonry_entries_query', 'avia_custom_query_extension', 10, 2); add_filter('avf_magazine_entries_query', 'avia_custom_query_extension', 10, 2); add_filter('avia_blog_post_query', 'avia_custom_query_extension', 10, 2); function avia_custom_query_extension( $query, $params ) { if(is_user_logged_in()) $query['post_status'] = array('publish','private'); return $query; }
Cheers!
PeterSeptember 13, 2018 at 3:06 pm #1009427Thanks, Peter!
I still encouter related problems with this in my main-installation e.g. with the tag-cloud.
So perhaps you could leave this open for some days more while I create a new thread for the other problem.Thanks for your help again.
September 13, 2018 at 3:13 pm #1009435Hi,
I’ll leave it open. Please note the tag cloud widget is a standard wordpress widget and it’s probably no theme issue (if you search for “tag cloud private posts” you’ll find useful information).
Best regards,
PeterSeptember 13, 2018 at 3:13 pm #1009436Hi Peter,
perhaps you could jump over to the thread I opened because you are already comfortable with the installation we used to solve our problem?September 13, 2018 at 3:26 pm #1009443Hi,
I answered there.Best regards,
Peter -
AuthorPosts
- You must be logged in to reply to this topic.