Hook for changing excerpt content when excerpt not set

The proper hooks for modifying the post excerpt are the ones you already tried: get_the_excerpt and the_excerpt, and WordPress actually uses the former one to generate an excerpt from the full post content, if there’s no custom or manually-specified excerpt for the post — below is the relevant code in wp-includes/default-filters.php: add_filter( ‘get_the_excerpt’, ‘wp_trim_excerpt’, 10, … Read more

Remove Header and Footer if user is not logged on

You have a lot of ways to do this. The first important thing is next: You must have a header or a footer (default header and footer, from WP) if you want to have functionality. E.g If you are loaded scripts or styles in function.php they will be broken, because you can’t load them without … Read more

Modify existing plugin function with add_filter

So you’re half way there with the code you have, you’re only missing a small part which is that your filter function takes information about what it’s filtering through function parameters, can then make changes to the thing that’s being filtered (or not) and then must pass that back out (return it). I.e. In this … Read more

Change the Default Plugin page filter to Active intead of All

There is no WordPress hook to filter the current status on the plugins admin, but if you must, you can use $_REQUEST[‘plugin_status’] to change the default status. See example below where I use the load-plugins.php hook to ensure we’re changing the status (or modifying the superglobal $_REQUEST) only on the plugins.php page: function wpse_373622() { … Read more

What are admin hooks

The init hook is triggered a little earlier than the admin_init. Between them is triggered wp_loaded and few hooks related to updating the DB. The init hook fires when WP is finished loading (viewer-facing and administration side). The admin_init hook fires on administration side only (/wp-admin/*), therefore is triggered also by front- and back-end ajax … Read more

How to exclude a taxonomy from shop & search page wooCommerce?

This might help you with Shop page listing: https://docs.woocommerce.com/document/exclude-a-category-from-the-shop-page/ And for Search page, here is a snippet that might help: function exclude_services_category_products_from_search( $query ) { if ( is_search() && !is_admin() ) { $array_with_service_category_id = []; $tax_query = $query->get( ‘tax_query’ ) ?: []; $tax_query[] = [ ‘taxonomy’ => ‘product_cat’, ‘terms’ => $array_with_service_category_id, ‘field’ => ‘term_id’, ‘operator’ … Read more

Update variable value via add_filter

Filters only allow you to directly modify the first value passed to them. In your case, that’s null. If you shifted view_slug up a place, it would be available to filters using your events_view_html tag. add_filter( ‘events_view_html’, ‘my_callback’, 10, 3); // passing 3 args to the callback, assuming you need them for something. function my_callback( … Read more