New answers tagged

0

save_post didn't work for me. What works in my situation is using content_save_pre filter or the content processing before save. Since I'm using Advanced Custom Field plugin for my cover_image field, and I ended up using acf/save_post filter to process the field.


0

apply_filters requires you to pass the value to be filtered in the 2nd parameter of this function (after the hook tag name) $error = apply_filters('check_for_more_errors', $error, $userid); add_filter('check_for_more_errors', 'error_check_1', 1, 2); function error_check($error, $userid){ $error[] = get_user_meta($userid, 'Plugin 1 user error', true); ...


0

You could take a cautious approach in your hooked functions and test whether you are on the front end or admin of the site. You could search the latest WP source for the hook you are using and see where it will have an impact.


1

image_send_to_editor hook will handle when the image is sent to the editor. The problem will be that your editor may not work correctly when you modify the URL -- use with caution. save_post will allow you to modify the $post content on save. update_(meta_type)_metadata could be used to intercept when the meta data is saved.


0

This is working for me $shortcode = 'book'; $pattern = get_shortcode_regex(); // if shortcode 'book' exists if ( preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches ) && array_key_exists( 2, $matches ) && in_array( $shortcode, $matches[2] ) ) { $shortcode_atts = array_keys($matches[2], $shortcode); // ...


0

I think you can simply use: post_class( 0 === $featured_posts->current_post ? 'first' : '' ); to add the first class directly within your template code, instead of applying the post_class filter.


1

I have been looking around the core files searching for hooks, there were very few when it comes to hooking into edit_user() function which updates the user data in profile.php page, so I have finished with some workarounds: My workaround is to save the user's password in a custom option before the password was updated, and match later with this user's ...


0

It works for me. add_filter('post_link', 'locale_permalink', 10, 3); add_filter('post_type_link', 'locale_permalink', 10, 3); function locale_permalink($permalink, $post_id, $leavename) { if (strpos($permalink, '%category_slider%') === FALSE) return $permalink; $post = get_post($post_id); if (!$post) return $permalink; if ($post->post_type != '...


0

As of WordPress 3.0.0 this action is available at the top of the new user form: user_new_form_tag As of WordPress 3.7.0 this action is called at the end of the form (right before submit button): user_new_form You will however need to intercept when clicking submit to save any specific user information to the user's meta


0

Add this code in functions.php function my_function() { echo'<div id="from_my_function"></div>'; } add_action('wp_head', 'my_function');


0

This is the finally code that is working like a chram <?php $taxonomy = get_taxonomy( get_queried_object()->taxonomy ); $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); get_header(); ?> <h1 class="page-title">Θέσεις εργασίας για <?php echo $term->name; ?></h1> ...


5

You can just remove the filter before calling the_excerpt and then add it back afterwards... remove_filter('excerpt_more','new_excerpt_more'); the_excerpt(); add_filter('excerpt_more', 'new_excerpt_more');


2

There's a filter for the output $job_listings_output = apply_filters( 'job_manager_job_listings_output', ob_get_clean() ); so, you should just do add_filter('job_manager_job_listings_output','my_job_manager_job_listings_output'); function my_job_manager_job_listings_output($output) { $adsense_code = ' My adsense code'; return $output . $...


1

You need to make a custom query to display these pending posts. Here is an example using get_posts(): $args = array( 'post_type' => 'post_type_name', 'post_status' => 'pending', // -1 shows all 'posts_per_page' => -1, ); $pending_posts = get_posts( $args ); foreach( $pending_posts as $pending_post ) { // post object properties ...


2

I've tried the same thing and was able to hook into the pre_option_ filter by using all as filter. add_filter('all', 'pre_option_',1,3); function pre_option_($actionHook,$bool=false,$option_name) { if(strpos($actionHook,'pre_option_') === FALSE){ return $bool; } }


4

I ran your filter in my development area. It didn't work. Then I switched off the Yoast SEO plugin, which I knew was also messing with the page title. Then it worked. So my suggestion would be it is another plugin that is messing with it. In the case of Yoast, it was a filter call to pre_get_document_title that returned non empty. In that case ...


0

You can add more than one filter call, so each of your custom meta_key's can be handled in separate code and when executed will cumulatively adjust the query. Perhaps look at the pre_get_posts filter rather than parse_query (although the solution I'm suggesting could possibly work in either case). pre_get_posts gives you access to the current query before ...


3

After some experimenting I came to the following suggestion: could it be, that the <title> tag is "hard coded" inside your parent theme's header.php? If that is the case, you could try to remove the <title> tag from your child theme's header.php (copy your parent's header.php into your child theme folder) and then add the theme support back ...


3

Having read your post from top to botom and bottom to top, you have in all probabilty a filter that is passing a title through the pre_get_document_title filter. The clue here the following statement: I've also tried pre_get_document_title, which does fire on page load, Looking at the soure code for wp_get_document_title(), we see the following code: ...


0

The function is_admin() is available before any plugin is loaded. So you can use it when you are registering the callback: is_admin() or add_filter('acf/load_value', 'word_swap' );


2

You need the !is_admin() check. This will return false on admin pages, failing your condition. On front end pages, that condition will return true, executing your conditional statement if ( !is_admin() ) { // Do something only on frontend }


2

If the parent theme does not declare support for title-tag you can do it like this in child theme /** * Theme support should be added on `after_setup_theme` */ function add_theme_support_child() { add_theme_support( 'title-tag' ); } add_action( 'after_setup_theme', 'add_theme_support_child', 11 ); Filter document_title_parts expected return type ...


0

Take a look at kfriend's solution here...it works. Not sure if it carries any other risks but it does work. http://stackoverflow.com/questions/772510/wordpress-filter-to-modify-final-html-output You can pretty much replace anything with anything else, using this.


0

There is no "filter everything" function. WordPress does something with their capital_P_dangit() function that attaches to 'the_title', 'the_content', and 'comment_text'. https://developer.wordpress.org/reference/functions/capital_p_dangit/



Top 50 recent answers are included