wp_posts table extremely large

Most of the space in that table in your case is taken by the overhead. 919MB is full size, with 885MB of overhead. Overhead is caused by the storage and index write operations in the MyISAM database engine storage. You can run this query to clear overhead: OPTIMIZE TABLE `wpwn_posts` Or, you can convert all … Read more

Move posts from a non-wordpress site to wordpress

If the previous posts are a service supported by WordPress’ importer you could try using that. https://wordpress.org/support/article/importing-content/ If that doesn’t support your previous blog service you could try WP All Import http://www.wpallimport.com/ I’ve used both of these methods with pretty good success.

Edit post locked notification dialog on edit post screen (post.php)… hook maybe?

I believe the easiest approach is to hide that Preview button via CSS. Here is a snippet or you can add that style to a pre-existing wp-admin stylesheet that you might have already included. add_action( ‘admin_head-post.php’, function(){ echo ‘<style>’; echo ‘.edit-post-header__settings .editor-post-preview { display: none !important; }’; echo ‘</style>’; }); I tried digging through the … Read more

How to retrieve all wordpress posts (specific type) inside a function in php?

Make sure you’re namespacing the class that is declaring the function, within chapters.php – namespace absf/Chapters Within down-latest-videos.php: use function absf\Chapters\get_down_latest_videos; // This pulls in the function from chapters.php $latest_four_vids = get_down_latest_videos( $post_id ); Your function get_down_latest_videos is expecting one argument to be passed – $post_id. You’re passing it two – $curated_posts and $program_ids. Since … Read more

Increment paged on WP_Query

You need to create a new WP_Query instance with the updated arguments. I will usually write it like this $args = [ ‘post_type’ => ’employee’, ‘post_status’ => ‘any’, ‘posts_per_page’ => 10, ‘paged’ => 1, ]; $query = new WP_Query($args); while ($query->have_posts()) { // your logic goes here // foreach ($query->posts as $custom_stuff) {} // prepare … Read more

Store metakey value as an array

I don’t think WP_Query returns the meta fields for you as well. So you need to loop over the posts and run get_post_meta() manually. Assuming one office has at max one _octopus_id, you could write it like this: // here we will store the ids $octopiIds = []; $query = new WP_Query([ ‘post_type’ => ‘office’, … Read more

Array to string conversion on array_map

Look closely at $offices: array (size=500) 0 => array (size=1) ‘id’ => string ‘1382’ (length=4) 1 => array (size=1) ‘id’ => string ‘1330’ (length=4) That is not an array of IDs. It’s an array of arrays. $offices[0] is not ‘1382’. It’s an array. So implode() on $offices is trying to concatenate arrays, which is what’s … Read more

How to display the featured post on the category page?

The problem is not in code to Displaying Feature post in category page. the problem is to add feature post meta into post. First, checked() by default echo, so you have to pass false attribute to prevent echo. function add_featured_meta_box($post){ $featured = get_post_meta($post->ID, ‘_featured-post’, true); echo “<label for=”_featured-post”>”.__(‘Feature this post?’, ‘foobar’).”</label>”; echo “<input type=”checkbox” name=”_featured-post” … Read more