How to create a WP_Query to search the Title or Tag?

Please use below code to show posts in texonomy and titles $s = $request[‘s’]; $tags = str_replace(‘ ‘, ‘-‘, strtolower($request[‘s’])); $q1 = get_posts(array( ‘fields’ => ‘id’, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘s’ => $s )); $q2 = get_posts(array( ‘fields’ => ‘ids’, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘tag’ … Read more

How to remove “out of stock” variation options from size dropdown in woocommerce?

Initially. It should be said that WooCommerce is considered a plugin and therefore your question could probably be flagged as ‘Off-topic’. This (however) is such a bullshit and self-deprecating for this StackExchange, so I’ll answer it anyway. 🙂 But next time you have a WooCommerce-question, you should ask it on StackOverflow (apparantly). My first thought … Read more

Append code into wp-config.php

This commands prepends a line at the beggining of yourfile sed -i 1i”define(‘WP_CACHE’, true);” yourfile To look for many files named wp-config.php and prepend the same text, type this in the shell: for i in $(find . -name wp-config.php) do sed -i 1i”define(‘<?php WP_CACHE’, true); ?>” $i done Run this from the main folder where … Read more

Real time Duplicate title check

You can hook ‘save_post’ or ‘wp_insert_post’ (both executed the same in wp_insert_post()) to check for autosaves and notify the author(s) accordingly. The checks that I would do would be to check that the author of the autosave (aka, revision) and the new autosave are not the same, check that the post title is the same … Read more

WordPress admin never finishes saving page on site with large page count

Have you tried optimizing and repairing the table in your MySQL database you are running WordPress on? Your can manually do this with phpmyadmin: http://support.hostgator.com/articles/specialized-help/technical/how-to-optimize-a-mysql-database-using-phpmyadmin Or you can install a WordPress plugin such as WP Database Optimizer and set a regular optimization schedule: http://wordpress.org/extend/plugins/wp-database-optimizer/

Debugging upload problem: What part of WP does actual image-resizing?

You can add a filter to wp_image_editors and see what editor is in use (GD or Imagick). In a past project I’ve extended the resize routines on both GD, and Imagick, and the methods responsible for resize are WP_Image_Editor_Imagick->crop() and WP_Image_Editor_GD->_resize(). Note that WP_Image_Editor_GD->resize() is just a wrapper. The process it’s run on ajax, but … Read more

Custom HTML structure in wp_list_categories

In case someone finds this someday I was able to solve this and I used tis walker: class Navigation_Catwalker extends Walker_Category { // Configure the start of each level function start_lvl(&$output, $depth = 0, $args = array()) { $output .= “”; } // Configure the end of each level function end_lvl(&$output, $depth = 0, $args … Read more