add_filter to wp_nav_menu_objects having no impact

First: Your ad_filter_menu is a filter function: it filters/manipulates $sorted_menu_objects That’s why you always have to return the $sorted_menu_objects, and return ”; won’t work. Second: A better way to achieve the desired behavior (adding thumbnails to navigation) is to extend the Walker_Nav_Menu class There are several guides and templates out there that fix this for … Read more

Using preg_replace() with the_content filter

Turns out I had multiple problems, @bonger pointed out the first one and then I found and solved issues with the global flag on the regular expression not being valid in php and me not accounting for links without a / after the .com. Final fix looks like this: add_filter(‘the_content’, ‘linkAppend’); function linkAppend($content) { global … Read more

How can you wrap add_filter with a if is_home() statement?

The is_home() function isn’t available until the parse_query action. So you’d probably want to rewrite your code like so: if ( ! function_exists( ‘df_excerpt_more’ ) ) { function df_excerpt_more( $more ) { return ‘ &hellip; <a class=”more-link” href=”‘ . esc_url( get_permalink( get_the_ID() ) ) . ‘”>’ . esc_attr__( ‘Read More’, ‘applique’ ) . ‘<i class=”ion-ios-arrow-thin-right”></i></a>’; … Read more

Woocomemrce order and registration fileds to UPPERCASE

First add the following code (and probably the WC Test Payment Gateway) and do a test order to get a list of all the data keys that are set in the order process via the woocommerce_after_checkout_validation filter: add_action(‘woocommerce_after_checkout_validation’,’custom_modify_order’,10,1); function custom_modify_order($posted) { foreach ($posted as $key => $value) {$data .= $key.”:”.$value.PHP_EOL;} $fh = fopen(get_stylesheet_directory().’/orderdebug.txt’,’w’); fwrite($fh,$data); fclose($fh); … Read more

Add a filter to an action [closed]

The action name suggests it is run _after_the_content, not within the the_content itself, so you might have to do something different here like @SamuelElh is suggesting… You would add a function to the action with early priority to buffer, then add a filter to the final output with a late priority: add_action(‘tribe_events_single_event_after_the_content’,’tribe_events_single_event_buffer_start’,0); function tribe_events_single_event_buffer_start() {ob_start();} … Read more

apply_filters with multiple args and multiple add_filter

apply_filters requires you to pass the value to be filtered in the 2nd parameter of this function (after the hook tag name) $error = apply_filters(‘check_for_more_errors’, $error, $userid); add_filter(‘check_for_more_errors’, ‘error_check_1’, 1, 2); function error_check_1($error, $userid){ $error[] = get_user_meta($userid, ‘Plugin 1 user error’, true); return $error; } add_filter(‘check_for_more_errors’, ‘error_check_2’, 2, 2); function error_check_2($error, $userid){ $error[] = get_user_meta($userid, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)