Child theme functions.php not executing

Our problem was that our style.css file was in a css folder inside the child theme directory, not at the root of the child theme. When we placed a style.css file at the root and included the comment block with theme name and template it picked up the functions.php file as expected.

Creating loop within functions.php

Just loop over WP_Query::$posts to get the titles: $option_posts = new WP_Query( [ ‘post_type’ => ‘organisationer’ ] ); $options = []; foreach ( $option_posts->posts as $post ) { $key = “option_{$post->ID}”; $options[ $key ] = apply_filters( ‘the_title’, $post->post_title ); } woocommerce_form_field_radio( ‘custom_field’, array( /* … */ ‘options’ => $options ), $checkout->get_value( ‘custom_field’ ) ); I’m … Read more

Display more recent and less recent posts in same category

The challenge: Get n = quantity older and newer posts from the recent posts with the same categories and/or tags. The solution: Like @TwerkingN00b suggested, we do need some custom SQL here. The magic SQL phrase we are looking for is UNION. UNION is used to combine the result from multiple SELECT statements into a … Read more

Theme-Config tab in admin Pannel?

It’s not classified as plugins. It’s also not a WordPress glossary and often called: Tabs which are built on Settings API and some tricks with $_GET request. There’re many Q&As, references you can learn from. This topic seems to be the most relevant one for you. Yes, you can do it with template_include filter. These … Read more

add_filter priority problem

The get_avatar filter accepts 6 parameters, not 5. The $id_or_email can also be an instance of WP_Post, WP_User or a md5 hash string. So it’s better to extract $user_id like this: if ( is_numeric( $id_or_email ) ) { $user_id = $id_or_email; } elseif ( is_string($id_or_email) ) { if ( is_email($id_or_email) ) { $user = get_user_by(’email’, … Read more

Conditions for Users and Visitors

EDIT You just need to add a custom hook to anything after parse_request and attach your coming soon content or redirect to that hook as you see fit. Hooking earlier then parse_request will cause WP to not be able to redirect /wp-admin/ to wp-login.php. You could also use php redirect if that is the behaviour … Read more