get_posts() and filters

the_posts does work for all queries including the main query as well as custom queries but doesn’t work when using get_posts(). This is because get_posts() automatically suppresses all the filters. If you want to use the filters even when using get_posts, you can pass an extra key ‘suppress_filters’ => false in the array you pass … Read more

Walker_Nav_Menu doesn’t work in wp_page_menu_args filter

Old Q, but I’ll give my 2 cents. The walker class should inherit Walker_Page, not Walker_Nav_Menu as is usually the case with guides on the ‘net. The $item object is a Post Object, containing post_title and ID. To output the URL, you need to call get_permalink($item-ID). Regarding $item->url, it will be unset. Both theme_location and … Read more

Filter custom post type using multiple taxonomy dropdowns

Right, seems a little empty here but I figured out the problem myself, again. The trick was to have empty values in the $output variables. So $output .=”<option value=””>Select taxonomy #1</option>”; NOT $output .=”<option value=”#”>Select taxonomy #1</option>”; This is how you can create two dropdown menus and filter out your posts using your custom taxonomies. … Read more

String regex match replace for role ‘contributor’ only

There’s author_can() for that: add_action( ‘loop_start’, ‘wpse105294_nofollow_author’ ); function wpse105294_nofollow_author() { ! author_can( $GLOBALS[‘post’]->ID, ‘edit_others_posts’ ) AND add_filter( ‘the_content’, ‘cn_nf_url_parse’); } So you only add that filter callback for authors and other roles that don’t have the possibility to edit_others_posts. By default this is Subscriber and Author. For more info, take a look at the … Read more

Capture post content before page renders

WordPress does not concatenate the entire page into a string before printing it which is what would have to happen to “capture” the whole page template. Much of the page echos as it occurs– think about template tags like the_content and the_title which don’t return strings. The just echo them. You’d have to use output … Read more

Post Content, Special Characters and Filters

Using a snippet of code like this: $hook_name=”the_content”; global $wp_filter; var_dump($wp_filter[$hook_name]); I was able to find a list of all hooked callback functions to the WordPress filter: the_content. I then located a few possible culprits, then searched for their function existence. After narrowing down my list, I came to the conclusion on the hooked callback … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)