Articles of filters

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 […]

register_taxonomy and register_post_type does not work

I have a problem using the register_post_type and register_taxonomy on my WordPress. I created the code on my functions.php and it does not update my panel. Why? //Categorias personalizadas register_taxonomy(‘produtos’, ‘produto’, array(‘hierarchical’ => true, ‘label’ => ‘Categorias de Produtos’, ‘query_var’ => true, ‘rewrite’ => true)); //Posts personalizados add_action(‘init’, ‘create_post_type’); function create_post_type() { register_post_type(‘produto’, array( ‘labels’ […]

WordPress 3.2(Multisite) – How to add custom user meta fields to signup form?

I want to add custom user meta fields to registration page. I use WP multisite so I have to modify wp-signup.php. Adding some field is easy for me(I am programmer :P). But I have a problem with this line of code: wpmu_signup_user($user_name, $user_email, apply_filters(‘add_signup_meta’, array())); I have searched all WordPress with bash command: find -name […]

Title_save_pre – Simple problem that u know for sure

I have two custom post type. Then I need to use title_save_pre to post title prior to saving it in the database. I need to use this filter just for one custom post type. This is my function: <?php function muda_titulo() { global $post; $type = get_post_type($post->ID); if ($type== ‘event’) { $title = $post->post_excerpt; $day= […]