File tree 1 file changed +13
-4
lines changed
1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -739,16 +739,22 @@ function fictioneer_add_chapter_story_filter_dropdown( $post_type ) {
739
739
function fictioneer_filter_chapters_by_story ( $ query ) {
740
740
global $ post_type ;
741
741
742
+ // Abort if...
743
+ if ( ! function_exists ( 'get_current_screen ' ) ) {
744
+ return ;
745
+ }
746
+
742
747
$ screen = get_current_screen ();
743
748
744
749
// Make damn sure this is the chapter list table query
745
750
if (
746
751
! is_admin () ||
747
- empty ( $ screen ) ||
748
- $ screen -> id !== ' edit-fcn_chapter ' ||
752
+ ! $ query -> is_main_query ( ) ||
753
+ $ query -> query_vars [ ' post_type ' ] === ' fcn_story ' ||
749
754
$ post_type !== 'fcn_chapter ' ||
750
755
empty ( $ _GET ['filter_story ' ] ?? 0 ) ||
751
- $ query ->query_vars ['post_type ' ] === 'fcn_story '
756
+ empty ( $ screen ) ||
757
+ $ screen ->id !== 'edit-fcn_chapter '
752
758
) {
753
759
return ;
754
760
}
@@ -765,6 +771,9 @@ function fictioneer_filter_chapters_by_story( $query ) {
765
771
// Apply to query
766
772
$ query ->set ( 'meta_query ' , $ meta_query );
767
773
}
768
- add_action ( 'pre_get_posts ' , 'fictioneer_filter_chapters_by_story ' );
774
+
775
+ if ( is_admin () ) {
776
+ add_action ( 'pre_get_posts ' , 'fictioneer_filter_chapters_by_story ' );
777
+ }
769
778
770
779
?>
You can’t perform that action at this time.
0 commit comments