Articles of filters

Add mime types with plugin

I’ve tried a few plugins to add mime types including the PJW Mime Config plugin. And adding this to a themes functions.php file would work fine, too, for a non-WPMS site. But I need these to be allowable throughout the network. So I’ve written my own plugin to do the trick. After looking at info […]

Custom Queries – Child Categories not showing up

What I’m Doing I have a cities category and normal categories. Right now I have them filtering by category, then when the user clicks a city it will filter by category AND city query_posts(array( ‘category__and’ => array($city, $category)) The Problem That works – no problem. The problem comes when I add sub-categories to my main […]

CSS class on last post in loop ( custom query )

I have been using this question to try to do this but I am having some difficutlty. I have a custom post type, media, and I am working on the archive-media.php template. I have it partially working in that when I delete the if condition out of the code it does add the class, but […]

How to add a filter to the get_body_class function?

I see it is possible to use add_filter with the body_class function, but I’m needing to add one to the get_body_class function. How can I add a filter to a function that is not included in the list of already available filter hooks? Thanks.

Generating rel=prev and rel=next only on wordpress categories

I was trying to remove the rel=prev and rel=next tags from my website as my SEO gut suggested. I found those functions which perfectly do the magic: remove_action(‘wp_head’, ‘start_post_rel_link’, 10, 0 ); remove_action(‘wp_head’, ‘adjacent_posts_rel_link_wp_head’, 10, 0); however, after a while my SEO guy suggested to leave it on a categories section where over there it’s […]

Currently using a query_posts() in my theme – want to use a request filter in stead

I am currently using this code in my theme right before showing the content of the custom post type my_post_type: $title = $post->post_title; query_posts( array ( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘my_taxonomy’ => $title )); This means that when I go to …/my_post_type/some_title, I see all pages that are assigned “some_title” as my_taxonomy. Now […]

get_query stops working after post filter

I’m currently trying to set up some filters for a custom post type within my admin. The custom post type is ‘players’ and I’m filtering them by another custom post type ‘teams’. To create my dropdown list of teams I use get_posts to retrieve all my teams: $args = array( ‘numberposts’ => -1, ‘post_type’=> ‘team’, […]

Using dynamic conditions in 'posts_where' filter

I have the following code which gives be posts that are published in the last 100 days function smbd_cats_by_days ($where = ”) { $where .= ” AND post_date < ‘” . date(‘y-m-d’, strtotime(“-100 days”)) . “‘”; return $where; } add_filter(‘posts_where’, ‘smbd_cats_by_days’); It is working fine. But now I want to make this function generic. (ie) […]

wp_nav_menu action/filter help

Maybe an odd question, I have a site that makes heavy use of nav menus. I’m looking to improve my site’s performance, and since the menus hardly ever change, I wrote some PHP to spit them out into static files. What I can’t figure out though, is if there is a way for me to […]

Should I remove_filter in order to replace a filter?

If a plugin modified one of wp’s filters by “add_filter”, and I want to discard the modification and modify the wp’s filter by my own codes. Should I remove the plugin’s filter before I add my own filter?