Keep WordPress blog up to date [SEO]

To signal the search engines that something happens on your blog

 Keep your blog up to date. 
Look at old posts again and adapt them.

I’ve been busy with SEO-related topics lately and came across a tip, which sounds very logical to me. You always have to keep your old posts up to date to keep them in good position on Google.

What can I do?

I write posts daily and can not always stay on the “published posts” page and pick out random ones.

That’s why I wanted to write a script, which redirects me to a random unchecked post and marks it as checked.

The code

I created two files.

  • random_post_menu.php
  • random_post.php

I then included the random_post_menu.php in my functions.php.

//...
require_once('inc/cron/random_post_menu.php');
//...

random_post_menu.php

I wrote this file to be able to get a random post in the backend at any time and, if necessary, to reset the statistics.

<?php
add_action( 'admin_menu', 'register_menu_page' );

function register_menu_page(){

add_menu_page( 'Check random', 'Check random', 'manage_options', 'random_post_redirect', 'random_post_page', 'dashicons-update', 5 );
add_submenu_page( 'random_post_redirect', 'Reset checked', 'Reset checked', 'manage_options', 'reset_checked', 'random_post_page' );


}

function random_post_page() {
	if($_GET['page'] == 'random_post_redirect') require_once("random_post.php");
	if($_GET['page'] == 'reset_checked'){
		foreach (get_posts(array(
			'lang' => '',
			'posts_per_page'   => -1,
			'meta_query' => array(
				array(
					'key'     => 'checked',
					'compare' => 'EXISTS'
				)
			)
		)) as $checked) {
			delete_post_meta($checked->ID,'checked');
		}
		?><script type="text/javascript">window.location.href = "<?= get_admin_url() ?>";</script><?php
		var_dump(get_admin_url());
		wp_redirect(get_admin_url());
	}
}

add_action( 'admin_menu', 'random_post_redirect' );

random_post.php

This file is for the identification of an unchecked post and the forwarding to a random unchecked post. I wrote that so I can access it anytime.

For example, I could mail me daily or weekly, reminding me to check a post. If this file is linked, the forwarding will happen automatically.

<?php
if ( !defined('ABSPATH') ) {
require_once("../../../../../wp-load.php");
}


$posts = get_posts(array(
	'lang' => '',
	'posts_per_page'   => 1,
	'orderby' => 'rand',
   'meta_query' => array(
      array(
         'key'     => 'checked',
         'compare' => 'NOT EXISTS'
      )
   )
));
update_post_meta(
	$posts[0]->ID,
	'checked',
	'1'
);
?><script type="text/javascript">window.location.href = "<?= 'https://talhasariyuerek.com/wp-admin/post.php?post='.$posts[0]->ID.'&action=edit' ?>";</script><?php

Conclusion

By using this feature permanently, you can signal to Google that your blog is developing organically and doesn’t get outdated.

If somewhere on the page, the search engines also can see when the page was last updated/modified, it can also be clearly assigned. You can pass this informations through structured data. How I did that you can read here:

Topics

Bing Experience Google php Program SEO Tips WordPress

Beitrag teilen

WhatsApp it