Articles of filters

End excerpt at the end of the sentence

I need to create an excerpt that doesn’t stop with an orphan word such as: All I’ve got to do is pass as an ordinary human being. Simple. What could possibly go wrong? Did I mention we have comfy chairs? I’m the Doctor, I’m worse than everyone’s aunt. catches himself And that is not how […]

How to remove xmlns on language_attributes()?

Hello I’am getting this error on w3c because xmlns is deprecated. How can I remove xmlns? Attribute xmlns:fb not allowed here <html lang=”en-US” xmlns:fb=”http://ogp.me/ns/fb#” xmlns:addthis=”http://www.addthis.com/help/api-spec” prefix=”og: http://ogp.me/ns#”> My code is <html <?php language_attributes(); ?>> function get_language_attributes( $doctype = ‘html’ ) { $attributes = array(); if ( function_exists( ‘is_rtl’ ) && is_rtl() ) $attributes[] = ‘dir=”rtl”‘; […]

add_filter comment_edit_redirect not working

In my plugin, I have this statement add_filter( ‘comment_edit_redirect’, ‘mcd_return_link’); and this function function mcd_return_link { return “edit-comments.php”; } Inside the comments.php (core file), is this section of code (within the section to edit comments, around line 310) (version 4.720 $location = ( empty( $_POST[‘referredby’] ) ? “edit-comments.php?p=$comment_post_id” : $_POST[‘referredby’] ) . ‘#comment-‘ . $comment_id; […]

Changing Order of Filters

I need to add some content before post content. I use follwoing code for it. function theme_slug_filter_the_content( $content ) { $custom_content = ‘My CONTENT GOES HERE’; $custom_content .= $content; return $custom_content; } add_filter( ‘the_content’, ‘theme_slug_filter_the_content’ ); Another plugin also add some content before post content. Now my single post look like this. Added Content From […]

Multiple filters for wp_get_archive

I need to display custom posts archives on a page in the following format: Monthly – Grouped by Month for the Current Year. Annually – Grouped by Year & Month for all previous years So I have got two functions to do so, which supposed to be called in a row: function show_monthly_archive( $post_type ) […]

Which action hook to use for function?

I’ve created a custom category template to display the current category’s child categories instead of posts. Child categories are displayed via a custom thumbnail, title and category description. I have added a function to trim the category description to a predefined number of characters, but I’m not sure which action hook to use. Here’s the […]

How to get image ID to use inside wp_read_image_metadata()?

I would like to automatically set the alternative text to be the same as the title of a post when image is uploaded. I have found this function which works good for setting caption. For updating alt text I believe I need to use update_post_meta($image_id, ‘_wp_attachment_image_alt’, $post_title); but how can I obtain image id? How […]

De-bloating the page classes

The standard page class in WordPress looks something like this; <body class=”page-template page-template-page-templates page-template-page-standard page-template-page-templatespage-standard-php page page-id-7 page-parent”> which if you ask me, is a bit bloated, I mean who is going to set up a css class .page-template-page-templatespage-standard-php ? And I do like human readable code. So my question is how to rewrite the […]

Shortcodes not resolved in AJAX call response

I have a simple function, which returns the content of a page with the given pageID: function get_page_content(){ $id = $_REQUEST[‘id’]; $page_data = get_page($id); echo apply_filters(‘the_content’, $page_data->post_content); //echo do_shortcode($page_data -> post_content); wp_die(); } add_action( ‘wp_ajax_nopriv_get_page_content’, ‘get_page_content’ ); add_action( ‘wp_ajax_get_page_content’, ‘get_page_content’ ); But after an Update of WP and some Plugins the returned content still containes […]

Overriding default calendar to show posts from a category

I’m trying to modify the default WP calendar (get_calendar()) so that it shows posts from a specific category and then use that as a shortcode. Here’s what I’ve done: Copied across the get_calendar() function from the core (from wp-includes) into my child theme’s functions.php file. In order to make it an ‘independent’ calendar, I changed […]