How can i create a function tag in my plugin

You are looking for Enclosing Shortcode. Here is an example of how you can achieve this. function example_shortcode($atts = [], $content = null) { // do something to $content // run shortcode parser recursively $content = do_shortcode($content); // always return return $content; } add_shortcode(‘example’, ‘example_shortcode’); Now you can use it like [example] Here is my … Read more

How to display category and tag descriptions in a post

First of all, remember that a post can have multiple categories, so you’ll have to handle an array and then print the results. To get see what categories are attached to your post, print the value from the get_the_category function inside a <pre></pre> (which formats the code): $categories = get_the_category(); echo ‘<pre>’; var_dump($categories); echo ‘</pre>’; … Read more

Hooking into the HTML header container

Unless a theme provides such a hook there is no way to do this with actions and filters. If a hook is provided then it will be theme specific, no generic WP solution exists. For a full list of the hooks that a theme should implement, see here: https://developer.wordpress.org/themes/advanced-topics/plugin-api-hooks/ At the moment this includes: wp_head() … Read more

Multiple Tag Filtering

I recently wrote a bit of code which filters by one tag at a time only, but it would be pretty easy to modify it to ‘toggle’ the status of each tag so that you could filter by multiple tags simultaneously. You can see it working here: http://sadcookbook.recipes/sad/ . It uses the following PHP to … Read more

How can I get my WordPress plugin to receive data and relay it in an ajax/php request to a remote server that requires authentication?

In your PHP to call the remote server you may want to look at the http and API functions availalble in WordPress here: https://developer.wordpress.org/plugins/http-api/ For example, here’s a much easier way to get data from a remote server: $response = wp_remote_get( ‘https://api.github.com/users/blobaugh’ ); $http_code = wp_remote_retrieve_response_code( $response ); And here’s a way to post like … Read more