change the default order of posts only for specific categories

Problem 1 $foo = is_category( … ); Is the same as: global $wp_query; // the main query $foo = $wp_query->is_category(….); So when filtering the query, don’t check the main query, check the query you’re filtering instead: $query->is_main_query() && $query->is_category( …. Problem 2 Look at this: array(‘573,1060,1061,1062,1063,1065,1066,1064’) You might think this is a list of 8 … Read more

Replace plugin function with a custom function?

For your question how can I replace this function . You don’t need to replace it. The function has a filter on the returns value, not an action. You don’t need to remove it, just filter the result. So you can create a new function and call it with add_filter(‘sep_the_event_end_date’, ‘yourfunction’); Put this in your … Read more

Init action and refresh page after form action

From the documentation: https://developer.wordpress.org/reference/hooks/init/ add_action( ‘init’, ‘process_post’ ); function process_post() { if( isset( $_POST[‘unique_hidden_field’] ) ) { // process $_POST data here } } In your example, perhaps having two different add_action is causing problems and burying your function where it’s not firing during init I’m going to test a similar solution and see what … Read more

How to properly refresh page after form action?

Searching around and not being able to implement the action through init hook I’ve found this workaround which for sure isn’t the best but does the job nicely. echo “<script type=”text/javascript”> window.location=document.location.href; </script>”; at the end of $_POST instructions. If somebody has a better solution, welcome to share.

How to load a script code only in posts?

In the active theme, functions.php file or in your plugin, function load_scripts() { if ( is_singular( ‘post’ ) ) { // Load the Javascript wp_enqueue_script( string $handle, string $src=””, array $deps = array(), string|bool|null $ver = false, bool $in_footer = false ); } } add_action( ‘wp_enqueue_scripts’, ‘load_scripts’ );