Home › Forums › Calendar Products › Events Calendar PRO › Make a specific Calendar catagory private
- This topic has 50 replies, 7 voices, and was last updated 8 years, 10 months ago by Support Droid.
-
AuthorPosts
-
August 18, 2012 at 7:03 am #23790BarryMember
Hi Andy! You’re perfectly correct of course – and if you want to give that a whirl (Phil) please do! You can find guidance on how to package up code as a plugin here.
The reason I shy away from suggesting this is that past experience tells me wrapping code in a plugin in this way can be a step too far for many people – who simply want to copy and paste code into a specific location (I’m not suggesting this is the case with you Phil!).
It’s a great idea though for those who are comfortable doing it 🙂
August 20, 2012 at 10:25 am #23828wortParticipantGreat idea, and something our people have been requesting. We’ve got it working for the calendar, but not the list, so far. Thank you!
August 21, 2012 at 7:01 am #23865Daniel DvorkinMemberHey guys!
This should do it. Please test it and let me know.
https://gist.github.com/3415684September 3, 2012 at 1:38 pm #24476PhilParticipantHow would I make this into a plugin?
September 3, 2012 at 1:39 pm #24477PhilParticipantEr nevermind, I see the link above. How would I combine the 2 different codes from Barry and Daniel to make this work as a plugin?
September 3, 2012 at 1:43 pm #24478Daniel DvorkinMemberHey Phil, my snippet works as a plugin.
You just need to add the plugin header (http://codex.wordpress.org/Writing_a_Plugin) and place it in wp-content/plugins/
Why do you need to combine the two codes?
Cheers!September 4, 2012 at 12:04 pm #24530PhilParticipantWasn’t sure if your snippet did both or if it needed to be combined with what Barry originally posted.
September 4, 2012 at 12:17 pm #24531BarryMemberYep Daniel’s code is the best choice here 🙂
And if you can wrap it up as a plugin you’ll be all set! Let us know if you need any further help.
September 4, 2012 at 12:29 pm #24533PhilParticipantOK, I think I typed up the plugin properly. When I uploaded it to my site and try it out I get the following warning and the event doen’t show on the calendar, even if I am logged in….
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/allsaintsmedia/fred_pres/wp-content/plugins/Events_Calendar-Private_event.php_/Events_Calendar-Private_event.php on line 35
September 4, 2012 at 12:30 pm #24534PhilParticipantHere is my code…
TribeEvents::TAXONOMY,
‘field’ => ‘slug’,
‘terms’ => array( ‘private’ ),
‘operator’ => ‘NOT IN’ );/*
* The we merge our new tax_query with the
* original one, so we don’t loose any category
* filter we may need to use in the Front End
*/$taxquery = array_merge( $taxquery, $query->tax_query->queries );
/*
* And at the end we add the new resulting tax_query
* to the main events query, _before_ said query
* so we don’t need to traverse the whole results
* and delete the events we don’t want to show.
*
* This is the equivalent of using pre_get_posts
* to filter things out in the standard WordPress
* way
*
*/$query->set( ‘tax_query’, array( $taxquery ) );
return $query;
}September 4, 2012 at 12:31 pm #24535Daniel DvorkinMemberPhil, can you post your code in http://pastebin.com/ and post here the link?
Thanks
September 4, 2012 at 12:37 pm #24536PhilParticipantHere is my plugin code…
https://github.com/skstarkiller/code/wiki/Private-Event-CodeSeptember 4, 2012 at 12:38 pm #24537PhilParticipantHere you go
http://pastebin.com/p0Vc9bdFSeptember 4, 2012 at 12:45 pm #24539Daniel DvorkinMemberInteresting. Your plugin doesn’t fail for me.
Where are you seeing that notice exactly?
September 4, 2012 at 12:49 pm #24540PhilParticipantI changed your hidden slug to private because that is the slug for my Private category. When I upload the plugin, then create an event and use the Private event category, when I update or publish the event I get that warning and then the event doesn’t appear on the calendar, even if I am logged in. It does however show in the backend list of events.
here is the link to the site being developed
http://fredpres.allsaintsmedia.com/events -
AuthorPosts
- The topic ‘Make a specific Calendar catagory private’ is closed to new replies.