You’re on the right path with your add_filter
, but this is the right way to implement filters.
add_filter( 'gigpress_related_post_types', 'my_related_post_types' );
function my_related_post_types( $post_types ) {
return array( 'productions' );
}
The hook add_filter
must call a function that returns something to pass to the apply_filters
in the code you referenced.
You should add in whatever logic you need to return the correct post types and handle the default as well. For example:
add_filter( 'gigpress_related_post_types', 'my_related_post_types' );
function my_related_post_types( $post_types ) {
// Assuming you set an option to control which post types should be used.
$custom_gig_post_types = get_option( 'gig_post_types', false );
if ( $custom_gig_post_types ) {
return $custom_gig_post_types;
}
return $post_types;
}
Related Posts:
- Issues with title-tag and document_title_parts
- Import WordPress XML File from Within Functions.php
- Define custom Page Template without its own .php file
- How to influence the information displayed on widget inside wp-admin
- Is there a hook or function I can use to display all theme files being used on a current page?
- Issue with get_theme_mod returning a blank value instead of the saved value
- Add action hook conditionally – only when home.php in use
- Show modified time if post is actually modified
- why doesnt is_home() work in functions.php
- Implementing DNS Prefetching with WordPress
- Help me to understand wp_header() and wp_footer() functions
- How can I tell if I’m on a login page? [duplicate]
- In WooCommerce I need to modify the thankyou.php page [closed]
- How can I add an extra WooCommerce hook
- Why get_header() or get_footer() does not run twice if called in the same php file?
- Remove Page Title from Static Frontpage
- How to override WordPress registration and insert an auto-generated username?
- Set default options for inserting media
- Change parent theme file function in child themes functions.php
- Adding extra SVGs to TwentyNineteen child theme using class TwentyNineteen_SVG_Icons
- How to hook into the quick edit action?
- gform_after_submission content appears immediately after , not in post body [closed]
- How do I change parameters without changing the core
- WooCommerce add_action hook results in 500 error
- Increment price for Woocommerce Minicart [closed]
- how to change link of some wordpress pages
- Gravity Forms field entries into wp_query loop [closed]
- Post thumbnail relative link and HTML modify
- Proper way of using functions in action hook?
- How to preserve edits to Name or Slug of term when using wp_update_term on save?
- Accepted arguments value in hook functions
- Get current page_id before loop, in functions.php
- How to properly add function called by action-hooked function to functions.php?
- Which action hook to use for function?
- Change size and crop medium_large images
- Inserting a functions output after the content
- How to display post content instead of excerpt
- Add function to every post?
- Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘greenday_head’ not found or invalid function name
- Modify a function without editing template
- Don’t delete a page if it holds users
- Problem only while using require_once() within functions.php
- Passing values from a widget to a function within a plugin
- Which action does wp_update_user triggers?
- How can I get my Script to work on the Login page?
- Trigger a custom function when option are saved in admin area
- Execute a ultimate member action when user role is updated
- Add other social networks to TwentyNineteen_SVG_Icons class in child theme?
- What did I do wrong in my functions code, that will not change the “Get New Password” text to “Send It”?
- Replace a menu with widget or a custom template file programmatically
- Footer disappears when using the_content ( )
- Get User Login Data (date, time… )
- Registration Hooks don’t appear to be working
- jQuery does not work
- Why does re-using this function not work? [closed]
- Override the WordPress core function wp_referer_field
- How to return hook data when multiple parameters are present?
- Hook into a function without a hook?
- What is the text that appears beside the page titles in the list of pages in the WP admin?
- How to edit the Tags within the image file URLs?
- Can’t properly set the_title add_filter to show short_URL
- Control the srcset much more (not all sizes in it each time)
- How to add_filter html template to middle of content
- Filter yoast canonical add_action priority [closed]
- (Woocommerce) Order by price when entering specific category
- Auto log in hook is requiring a page refresh
- Possible to hook into Media Library preview File column and use a custom image?
- Add back in child theme what the parent theme removed with remove_action
- Writing a function to detect an event
- WordPress wraps span tags into p tags
- Changing where my author box is printed
- Is it possible to use add_filter in an included file in the child theme’s functions.php?
- Insert Content Before div#main from the functions.php File
- Add Adsense code between job listings – wp job manager plugin
- Replace admin header logo with an image
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- is_home() not working in functions.php file
- How to place a div inside a function that creates a div
- Changing the text of Upload/Insert on Posts and Pages Screen
- Filter for replacing the WP_query object for a given category
- WordPress comment processing . Default unapproved comments detection before posting
- Does hook have an effect on increasing the page load?
- What is the earliest Hook a Script can use?
- Populate acf-field, depending on block name
- How Do I Unhook This Parent Theme Function?
- How to add custom column into custom post, when field is select
- True email confirmation for registration (keeping unvalidated users from user table)
- How to echo the translated custom field?
- Init hook for header send
- Why wp_ajax hooks doesn’t work?
- How can I append and prepend something to all post hyperlinks without using ::before or ::after? PHP hook solution?
- Why functions metaboxes is causing White Screen in Admin [closed]
- How do I add functionality to images?
- How to hook wp_mail to add a custom email as BCC for each sent email?
- image_size with respect to aspect ratios
- delete_term is not working properly with add_action()
- Get category of post inside save_post hook
- Create section wit form
- Log in and out using custom pages, no logout confirmation and redirects for logging in and out 2023
- Copy and Modified WooCommerce function is_coupon_valid [closed]