Outputting post content to jQuery .html() string

Well, just figured it out by using different search terms: https://stackoverflow.com/questions/10757671/how-to-remove-line-breaks-no-characters-from-the-string To remove HTML breaks from PHP returns (not actually called “line breaks” because they may get confused with the br tag) you’d have to use something like str_replace() with the \r and \n characters which are PHP breaks. In my case, this is what … Read more

Hide Plugin Custom Post Type Menu Link

Those methods that you were using, remove the page totally. If you were the plugin author I would suggest to create the admin page calling add_submenu_page with a parent id of null. Since you can’t change the plugin code the only way to achieve this is using CSS. Read this ticket for more information about … Read more

Sharing varible between two add_actions

First of all, the order in which you use add_action is not relevant. The only thing it does is keep a tab of actions to undertake once the hook is encountered. Only when there are several functions on the same hook, the priority of the added action becomes relevant (read more). So, if your global … Read more

Show sidebar only to author of post

The reason this is not working is because you are trying to use undefined variables, they are declared outside the function and can therefor not be used without prefixing them with the global keyword. If you have error_reporting enabled you would see warnings like this: Notice: Undefined variable: current_user in /… on line 11 Notice: … Read more

Default excerpt for parent of a custom post type

This will default the excerpt value in your custom post type only for new posts: add_filter( ‘default_excerpt’, ‘smyles_default_custom_post_excerpt’, 10, 2 ); /** * Default Excerpt for Custom Post Type * * @param string $post_excerpt Default post excerpt. * @param WP_Post $post Post object. * * @return string * */ function smyles_default_custom_post_excerpt( $post_excerpt, $post ){ if( … Read more

Find most used words in post titles

Below MYSQL query return the 10 most common value (words) in a post_title(column) FROM wp_posts(table): SELECT post_title, COUNT(post_title) AS Appearances FROM wp_posts GROUP BY post_title ORDER BY Appearances DESC LIMIT 10

Get parent category name when only child category is applied to a product

Check if it works for you… i have modified the loop /Woo Cat product $woo_single_cats = get_the_terms( $post->ID, ‘product_cat’ ); if ( $woo_single_cats && ! is_wp_error( $woo_single_cats ) ) { $woo_single_cat = array(); foreach ( $woo_single_cats as $term ) { $woo_single_cat[$term->term_id] = $term->name; $term_parent_id = $term->parent; $parent_term = get_term($term_parent_id, ‘product_cat’); } $woo_single_cat = apply_filters(‘seopress_titles_product_cat’, $woo_single_cat); … Read more