Setting custom canonical urls

It depends on how your canonical URLs are being written to the page. In your theme’s header you may find something like: <link rel=”canonical” href=”https://wordpress.stackexchange.com/questions/331598/<?php echo get_permalink(); ?>”> If you are able to edit your theme (or child theme if using a distributed theme) you can put whatever you want there instead. For instance, you … Read more

Custom form action to handle data inside a plugin

admin-post.php is perfect for that. You have to do three things: 1. Set action for your form to admin-post.php <form method=”post” action=”<?php echo admin_url(‘admin-post.php’); ?>”> 2. Add hidden input with name=action <input type=”hidden” name=”action” value=”my_plugin_action” /> 3. Register your callbacks for admin_post_{$action} and admin_post_nopriv_{$action}: add_action( ‘admin_post_my_plugin_action’, ‘my_form_processor’ ); add_action( ‘admin_post_nopriv_my_plugin_action’, ‘my_form_processor’ ); function my_form_processor() { … Read more

Add keywords meta to index.php page

I guess you use metadata to store keywords for other pages. One way if to use some page for the source of homepage keywords. Other is to add theme option for home page keywords: https://blog.templatetoaster.com/wordpress-settings-api-creating-theme-options/ Afterwards: add_action(‘wp_head’, ‘my_wp_head’)); function my_wp_head() { if ( is_front_page() ) { $keywords = get_option(‘homepage_keywords’); echo ‘<meta name=”keywords” value=”‘ . esc_attr($keywords) … Read more