Tag Info

New answers tagged

2

You will want to use the post_row_actions filter https://developer.wordpress.org/reference/hooks/post_row_actions-2/ For example, to add a link, you could try something like: function add_custom_link($actions, $page_object) { $actions['custom_link'] = '<a href="http://www.example.com">My Custom Link</a>'; return $actions; } ...


1

I can only suggest that you've got a 3rd party plugin or theme modification that is interfering somehow. I've tested your code exactly in several different installs and it works as expected. A few other things to consider: Is your environment behind a cache of some sort? Are you working in a child theme? Do you have another plugin installed that is ...


1

We can add the Featured option as a fake mime-type with: add_filter( 'media_view_settings', function( $settings ) { $settings['mimeTypes']['wpsefeaturedimage'] = 'Featured'; return $settings; }); It will show up like this: Then we can use the posts_where filter and check for our fake mime type: /** * Filter for featured images in the media ...


0

First: Your ad_filter_menu is a filter function: it filters/manipulates $sorted_menu_objects That's why you always have to return the $sorted_menu_objects, and return ''; won't work. Second: A better way to achieve the desired behavior (adding thumbnails to navigation) is to extend the Walker_Nav_Menu class There are several guides and templates out ...


0

You've already been pointed to the correct approach and the answer is functionally identical to any of the answers here about appending data to post content. All you need is something like: function my_function () { echo 'my function content'; } add_action('the_content','my_function'); To restrict that to single post pages: function my_function () { ...


0

I was able to fix it with this method. Is this good/bad? It's working, but I'd be interested in feedback in case this could have unexpected consequences. add_filter('gettext', 'translate_text'); add_filter('ngettext', 'translate_text'); function translate_text($translated) { $translated = str_ireplace('Very Weak', 'Bad', $translated); $translated = ...


0

This can be achieved by using the admin_url filter: function add_new_post_url( $url, $path, $blog_id ) { if ( $path == "post-new.php" ) { $path = "post-new.php?param=value"; } return $path; } add_filter( 'admin_url', 'add_new_post_url', 10, 3 );


1

The "Weak" text is passed through _x function, which calls translate_with_gettext_context, so I would try the following: add_filter( 'gettext_with_context', 'wpse199813_change_password_indicatior', 10, 4 ); function wpse199813_change_password_indicatior($translations, $text, $context, $domain){ if( $text == "Weak" && $context == "password ...


0

This post on Web Tips hooks into a few choice actions and filters to modify password strength allowances, but commenters seemed to have some trouble with it, so take this bit with a grain of salt. // functions.php add_action( 'user_profile_update_errors', 'validateProfileUpdate', 10, 3 ); add_filter( 'registration_errors', 'validateRegistration', 10, 3 ); ...


0

You can do it right in your theme localization file. Open *.pot file and create the translations for labels you need, e. g. OK for Weak. See password-strength-meter around line #366 in /wp-includes/script-loader.php for the reference (but don't change there anything). Update: I've found the solution using jQuery for the similar problem, but you have to ...


0

pre_get_posts filters will be applied to all queries on a page- the main query, menus, and additional WP_Query instances. To target only the main query, use is_main_query(): function my_pre_get_posts( $query ) { // bail early if is in admin // or if query is not main query if( is_admin() || !$query->is_main_query() ) { return; } ...


0

You can use "save_post" action-hook Add the code below into functions.php and enchance with your comment_meta code. function update_comments_meta( $post_id ) { // Do whatever add/update_comment_meta code you need } add_action( 'save_post', 'update_comments_meta' ); UPDATE. As an example i've attach code below. It performs on post save/update ...


2

With the lastest version of WordPress (4.3) you can now natively remove the customizer's theme switch setting without resorting to CSS hacks. /** * Remove customizer options. * * @since 1.0.0 * @param object $wp_customize */ function ja_remove_customizer_options( $wp_customize ) { //$wp_customize->remove_section( 'static_front_page' ); ...


0

First, always develop with debugging enabled. That white screen will now contain error messages to help you determine the problem. Refer to the action reference to see the order in which things happen during the load process. Your plugin is loaded before the plugins_loaded action, which is when your code runs. However, note that the current user isn't ...


0

Plugins run a lot earlier than themes - you need to delay the execution using a hook: /** * Fire once WordPress is ready and conditionally hook our handler. */ function wpse_199197_init() { $user = wp_get_current_user(); $allowed_roles = array( 'author' ); if ( array_intersect( $allowed_roles, $user->roles ) ) add_filter( ...


0

Follow the following steps to achieve your result, Use get_terms to fetch all of your parent taxonomies and render a drop-down with the title and setting a data attribute with the term ID. Please set the args "parent" to 0 and taxonomy to your taxonomy slug. Write a jQuery script to fire an AJAX on the above created drop-down. The AJAX should send the ...


0

See update and plug-in Git linked there. I'll link it again: The answer to the question is that comment_reply_link() may be the wrong hook. Full answer explained and implemented at https://github.com/CKMacLeod/WordPress-Nested-Comments-Unbound


2

Plugins are loaded before the theme which means that your apply_filters won't have any actual callbacks registered to it. Instead, you need to call your apply_filters sometime after the theme has been loaded. Something like this: /* Your plugin's file: */ add_action( 'init', 'my_lovely_funky_filters' ); function my_lovely_funky_filters() { /* Fire our ...


0

This is the correct method - except the function is apply_filters, not apply_filter. Hence your error.


1

Notice how it is singular? Comment, not comments? This capability is not designed to check if user can edit any arbitrary comment out there. It can only check if user can edit one specific comment and correct way to call it is current_user_can( 'edit_comment', $comment_id ). Unfortunately second argument is missing from current_user_can() function ...


0

I think, to debug this scenario, you should first try following to get all the capabilities for the current user and see whether edit_comment actually exists in it or not - $user_id = get_current_user_id(); $userdata = get_userdata( $user_id ); $allcaps = $userdata->allcaps; $output = print_r( $allcaps, true ); echo '<pre>' . $output . ...


0

Filtering gettext is horrible for performance. I would strongly recommend to try do it via any other approach. And if all else fails to add and remove filter with extreme precision around necessary parts. As for why it fails my educated guess would be — timing. It is quite common for strings to be centralized and processed early in the process. For example ...


0

You are abusing pre_get_posts badly with that code. With pre_get_posts the point is to alter the main query. By doing that you reduce the number of necessary queries and save some processing time, plus keep the WordPress globals-- $wp_query, for example-- neat for any other code that might need them. What you are doing is creating new globals and populating ...


1

I'm listing down the necessary hooks which will add, validate the custom fields on registration form as well as allow fields update from user profile page - //show field on WordPress registration form add_action('register_form','register_form_callback'); //handle validation add_filter('registration_errors', 'registration_errors_callback', 10, 3); //save ...


0

You can also foreach through the registered hooks like this: function remove_filter_in_class( $tag, $function_to_remove, $priority, $class ) { if ( isset( $GLOBALS['wp_filter'][ $tag ][ $priority ] ) ) { foreach ( $GLOBALS['wp_filter'][ $tag ][ $priority ] as $key => $function ) { if ( is_array( $function['function'] ) ...


1

No, you cannot do that, unfortunately, because get_header( $name ) doesn't have a filter for the $name (it only passes the name with the action call). However, if you are willing to modify the header.php file for each site with something like this right at the beginning of the file: <?php if ( apply_filters( 'load_custom_header', false ) ) { ...


0

Assuming that $GLOBALS['Pootle_Page_Builder_Render_Layout'] carries an instance of Pootle_Page_Builder_Render_Layout, the method panels_render() returns a string. So you can simply pass the method call as an argument to apply_filters(): $content = apply_filters( 'the_content', $GLOBALS['Pootle_Page_Builder_Render_Layout']->panels_render( ...


0

If you need to change the permalink structure, it can be done in admin panel. Go setting -> permalinks and chose what you need in general settings



Top 50 recent answers are included