is there a specific place where add_filter must be placed?

add_filter() and add_action() are available before any plugin is loaded. So you can use both in the first line of your plugin or theme. For readability I recommend to group action and filter registrations at the very top of your main file: in a plugin, the file with the plugin header in a theme the … Read more

Add a header before fields added with the attachment_fields_to_edit() filter

I’ve found out that you can use the tr attribute for creating entire rows: function my_attachment_fields_to_edit( $form_fields, $post ) { $form_fields[‘attachment-header’][‘tr’] = ‘ <tr> <td colspan=”2″> <h2>My title</h2> </td> </tr>’; $form_fields[‘attachment-url’] = array( ‘label’ => __( ‘URL’, ‘plugin’ ), ‘input’ => ‘text’, ‘value’ => get_post_meta( $post->ID, ‘_attachment_url’, true ) ); $form_fields[‘attachment-width’] = array( ‘label’ => … Read more

How to change the blog title with add_filter? details below

With the filter single_post_title, you can change the page/post title that is set in the <head><title>Page title</title></head>. If you want to change the title that you see in the page header. ( Which i think you want to do). Use this filter: add_filter(‘the_title’, ‘modify_all_titles’, 10, 2); function modify_all_titles($title, $id) { return ‘SOME TEXT BEFORE TITLE … Read more

WordPress tag cloud add more links

Yes, you can. WP_Widget_Tag_Cloud widget uses wp_tag_cloud to generate the tag cloud. And inside that function and at the end of that function you can find this: /** * Filters the tag cloud output. * * @since 2.3.0 * * @param string $return HTML output of the tag cloud. * @param array $args An array … Read more

Filter custom post types in archive

The problem is that you’re using term IDs in your URL, but that is incorrect. Use the term slug instead. For example, lets say we have a mytax term named helloworld with the term ID 1: example.com/cpt/?mytax=1 404 example.com/cpt/?mytax=helloworld a cpt archive filtered by the helloworld term

add_filter return value

Like so: function my_validate_username( $valid, $username ) { $sanitized = sanitize_user( $username, false ); $valid = ( $sanitized == $username ); return $valid; } add_filter(‘validate_username’, ‘my_validate_username’, 10, 2);

How do I add a listbox to the TinyMCE editor?

In the TinyMCE plugin i wrote, my listbox wraps selected text in HTML, i do that like this.. onselect : function(v) { // Set focus to WordPress editor ed.focus(); // Get selected text var sel_txt = ed.selection.getContent(); // If no text selected if( ” == sel_txt ) return null; var active_style = toggle_styles[v]; if( ‘undefined’ … Read more

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