i need function to make wordpress use custom tables for old posts

I have a site with about 24,000 posts and 200 posts daily and the database will get huge soon. So I plan to transfer the old posts to custom tables to reduce the database load. There's no need to show these posts on the site. I just want to keep it for search engines and avoiding sql_calc_found_rows problems. These are the three tables I have created:

wp_posts -> wp_custom_posts

wp_postmeta -> wp_custom_postmeta

wp_term_relationships -> wp_custom_term_relationships

I have transferred old posts to these tables manually using phpMyAdmin and use a function to make WordPress use my custom post table instead of wp_posts if the post does not exists in it:



//check if the post exists in the genuine posts table

$results = $wpdb->get_results($sql,"ARRAY_A");


//if exists then return

return $sql;


//else change the query

$sql = str_replace("$wpdb->posts","{$wpdb->prefix}custom_posts",$sql);



//echo $sql;

return $sql;




However, my old posts in this case show up with no meta and taxonomies values. because wordpress still use the the default meta and relationships tables not my cutomes tables so i need function(s) to replace the default wp_postmeta and wp_term_relationships with my custom tables i just dont know the hook or filter that i should use ..

Kemahiran: MySQL, PHP, Wordpress

Lihat lagi: want to make site, prefix search, prefix function, use case, wordpress query search, load posts, wordpress load posts, reduce sql, load posts wordpress, wordpress custom post search, wordpress search replace, sql reduce, wordpress filter post, wordpress hook, database search wordpress, sql default values, change search query, wordpress search database, php sql filter, search filter wordpress, search replace wordpress, custom function wordpress, wordpress search query, wordpress search engines, custom search wordpress php

Tentang Majikan:
( 5 ulasan ) cairo, Egypt

ID Projek: #4063968

Dianugerahkan kepada:


Dear Sir, I am here ready to help. Thanks. Best regards, Rain Solution

$40 USD dalam sehari
(19 Ulasan)