Create short URL with auto 301 redirect

What you’re trying to do, can be achived by simply using the parse_request hook; no need for the custom rewrite rule and tag. So remove this (and you should flush the rewrite rules — just visit the permalink settings page): add_action( ‘init’, ‘vacature_rewrite_rule’ ); function vacature_rewrite_rule() { … } Then use this modified function which … Read more

How to define a variable already defined in a plugin function?

This is fairly easy. First, you need to use a child theme. See the following on child themes if you are unsure what they are or how to use them. https://developer.wordpress.org/themes/advanced-topics/child-themes/ The theme you are using uses pluggable functions which makes them easy to override. Note the function in the theme is written like this… … Read more

Loop over Array and get the distinct ids

No, that’s because you are treating an array as an object and PHP doesn’t convert those types automatically. To get an individual element from an object you use: $my_object->Element1; To get an individual element from an array you use: $my_array[Element1]; You can even nest arrays. So if you have $my_array, where each element is another … Read more

Combine embed_oembed_html and oembed_result

This works, just don’t know if it’s the proper way to do it: Yes, the functions are the same so they’re equivalent. There is nothing wrong here. But if we dig a bit deeper, we see they’re not 2 filters for the same thing at all: embed_oembed_html filters the cached oEmbed HTML. oembed_result filters the … Read more

replace text in Sort Box

There is a filter for sort options that you can use, but it looks like there is already a Sort By: Popularity option there. You can see the filter here. You may want to check to see if other plugins or your theme are defining where the Sort By text is coming from. WooCommerce also … Read more

How to add no follow to specific links?

The replace code is replacing the whole a element content with <a rel=”nofollow”>. Here’s the correction: I used (.+?) between <a and href” and before and after /go/pluto/ to the closing >. Then in the replace, we put $1 $2 $3 etc. to keep them and add rel=”nofollow”. You can check in this test, and … Read more

How to make function appear in sentence?

You can use below code to display theme detail sentence. I have use wp_footer action,You can change hook as per your requirement. function logbook_info() { $theme_logbook = wp_get_theme(); $theme_name = esc_html( $theme_logbook->get( ‘Name’ ) ); $theme_uri = esc_html( $theme_logbook->get( ‘ThemeURI’ ) ); $theme_author = esc_html( $theme_logbook->get( ‘Author’ ) ); $theme_author_uri = esc_html( $theme_logbook->get( ‘AuthorURI’ ) … Read more

Please show me how to use an if/else statement in combination with wp_enqueue

I think something like the following should work. Uncomment the var_dump to double check you’re getting the saved theme mod value you’re expecting. If not, check the naming of your customizer setting and that it saved properly. function mytheme_styles() { $theme_dir_uri = get_template_directory_uri(); // enqueue common styles and scripts // wp_enqueue_style( $handle, $src = false, … Read more