Articles of hooks

What is the proper hook to use for recording a post view?

I’m creating a script for tracking post views in my future projects. I will use this code in my theme’s functions.php. What I’m asking is, how can I make sure a post view is recorded when a user actually hits the page? I considered hooking into init or wp, but I’m not sure using the […]

How can I count post views of REST API calls and update them in an ACF field?

I don’t know if I’ve complicated things a bit, so I’ll explain things from the top. I have a set up with a custom post type (news), which is exposed via the REST API. The main endpoint (/wp-json/wp/v2/news) returns a list of news items, which needs to be sorted by popularity. I tried a few […]

How do I add something to the “Edit Tag” page in wp-admin?

I have some term_meta that I would like to display on the “Edit Tag” page in wp-admin. I found the following two action hooks, but both don’t do what I want. edit_tag_form edit_tag_form_pre These hooks either add something inside the form at the start, or at the end of the form, but before the “Update” […]

Help with callback using do_action_ref_array

I’ve managed to get the behaviour I want by modifying some plugin code. However, I would like to move my modifications outside of the plugin code using the provided hook, but I can’t seem make it work. The hook uses do_action_ref_array. The situation is not helped by the fact that the only way I can […]

Can't save custom field on registration page

I have a WordPress Multisite build and I’m trying to add a custom field to the admin user registration form but the metadata isn’t saving in the initial form: after I create the user, I can go to the new profile page and the custom field will save. Here is my function to add the […]

How can i trigger an action manually?

I’m currently working with a Learn Management System and students can earn certificates after they completed a course. This certificate gets generated and has an “action hook” hooked to it, so i can hook in to modify it. My problem is now with the debugging: Every time i want to test my hook i have […]

Rewrite to load homepage for a different url

So I’ve been wondering if there’s a way to force WordPress to load the homepage template for a URL. Eg.: https://example.com/example/another-example/my-post-slug/ should load the template belonging to https://example.com but some widgets would display different data according to the slug in the URI. Maybe there’s an action or a hook that could do this? This would […]

Action hook save_post for newly created posts – $post object data is all empty

When a post is created, I need to auto-generate a PDF version of the post. The problem is that the global $post object is mostly empty except for the post ID. I need to get the newly created post’s slug because the name of the PDF file needs to match the slug of the page. […]

Configure WordPress to Generate Scheme-less Relative URLs

I have a WordPress site where the CSS and Javascript URLs/tags end up looking like this <link rel=’stylesheet’ id=’dashicons-css’ href=’http://example.com/wp-includes/css/dashicons.min.css?ver=4.7.8′ type=’text/css’ media=’all’ /> <script type=’text/javascript’ src=’http://example.com/wp-includes/js/jquery/jquery.js?ver=1.12.4′></script> Is it possible to configure WordPress to use scheme-less relative URLs? i.e to generate links that look like this? <link rel=’stylesheet’ id=’dashicons-css’ href=’//example.com/wp-includes/css/dashicons.min.css?ver=4.7.8′ type=’text/css’ media=’all’ /> <script type=’text/javascript’ src=’//example.com/wp-includes/js/jquery/jquery.js?ver=1.12.4′></script> […]

Are there action hooks for comments?

This is for a personal-use plugin I’m trying to make. I want to submit a comment from site A to my blog (sort of like sending trackbacks/pingbacks but a full comment). For instance, on site A I have a form with a name, url, and comment field. The data I enter in site A, I […]