Hot answers tagged

2

No, for this to work reliably you would need to register hooks, which can't be done. The only way to know if a template triggers a hook is to load the template and find out. There is a solution to your problem, but testing if a hook is available is not that solution.


1

Try adding to functions.php function filter_movies( $query ) { if( !is_admin() && $query->is_main_query() && $query->get('post_type') == 'movie') { $tax_query = array( array( 'taxonomy' => 'period', 'field' => 'slug', 'terms' => 'current', ), ); $...


1

If you want a parameter to be required for a post type's REST API endpoint you can use the rest_{$this->post_type}_collection_params filter to filter the $args of the GET endpoint: add_filter( 'rest_car_collection_params', function( array $query_params ) { $query_params['visible_to']['required'] = true; return $...


1

There are two ways to solve this. The first one is what you are trying, but you have to print out the value you get. Like this: print get_post_meta(); I don't recommend this for two reasons: You should keep your templates as simple as possible. Otherwise they become cluttered with fragments of business code which makes everything harder to maintain. ...


1

There are issues in the answer marked as correct. It will break the alignment class functionality, and is not actually adding to the classList, instead it is overriding it. And you will only be able to use that one solution for your whole theme. Instead you can use "registerBlockStyle()" to add a style variation to the list block, and set "...


Only top voted, non community-wiki answers of a minimum length are eligible