Tag Info

New answers tagged

-1

Just add: $query->query_vars['meta_compare'] = 'LIKE';


2

Two problems here: #1 You're missing the $accepted_args argument in: add_filter( $tag, $callback_function, $priority, $accepted_args ); Check out the Codex here for more info on that. #2 Note that $link . "?program_year=2016" is problematic, since it gives us this kind of link: /?p=123&preview=true?program_year=2016 But using instead ...


1

have a look this plugin Simply Show Hooks which will show you where all the action and filter hooks are, inline, in order, on the page you're looking at, and all the actions or filter functions that have been hooked to them. You can see in the screenshot how it does it. It does just what you've asked.


0

Okay, for anyone looking to include the WooCommerce review tab not on an actual single-product page here's the secret sauce: In your template file, you need: global $withcomments; $withcomments = true; Then add a filter for the comments template: //add filter to use our custom review template add_filter('comments_template','{{YOUR_HELPER_FUNCTION}}'); ...


0

Thanks EHerman for your solution. My simplified version of your script would use the HTTP_REFERER in the upload filter directly: function my_custom_upload_dir($path) { if(isset( $_SERVER['HTTP_REFERER'] )) { //parse url into array $referrer = parse_url($_SERVER['HTTP_REFERER']); $queries; // take the query part and parse it into array ...


1

After working on this for a bit and checking the GLOBALS variable for anything useful, it looks like the referring URL inside of the media modal is the same URL as my custom plugin page. Using that and splitting it up a bit I was able to confirm that I am on the approrpriate page. I'm sure that there are other, more elegant solutions out there, but this is ...


1

The reason the link isn't working is because you haven't formatted it correctly. This: return '<h3><a href="www.google.com">Hello World</a></h3>'.$content; Should be this: return '<h3><a href="https://www.google.com/">Hello World</a></h3>'.$content; To answer your other question: There are a lot of ...


1

Where in core ? These parts here and here, are responsible for overriding the image title with meta data: // ... cut ... // Use image exif/iptc data for title and caption defaults if possible. } elseif ( 0 === strpos( $type, 'image/' ) && $image_meta = @wp_read_image_metadata( $file ) ) { if ( trim( ...


2

We can style the table with CSS and dashicons. Example: For our video category, we can use for example: .edit-php .wp-list-table tr.category-video td.post-title strong:before { content: "\f126"; color: #ccc; display: inline-block; width: 20px; height: 20px; margin: 0 4px; font-size: 20px; line-height: 20px; font-family: ...


2

Here is an answer I recently did on another question, the same as your. Because the answer was never upvoted or accepted, I could not mark this question as duplicate, so I have deleted the answer in the other post and reposting it here. Please note, some points are not aimed at this issue and can be ignored, also, you will just need to make a few ...


1

This is the simple way to remove emoji. Add bellow code to your function.php remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'wp_print_styles', 'print_emoji_styles' );


1

If you check the source for admin-ajax.php you will notice that the admin_init hook fires and that the system checks $_REQUEST['action'] for hooks. Given that, you could hook to admin_init, check the "request" super global, construct wp_ajax_* and wp_ajax_nopriv_* values, then use has_action() to see if anything is hooked in.


3

Before we code and go into particulars, lets look at the problem at hand. First of all, any valid date format is valid in a custom field if you are not going to use it for comparisons and sorting When you are going to sort by date or do comparisons by date in a custom field, bullet point one should be ignored. There are only two workable formats which will ...


0

woocommerce_before_main_content is not a filter hook, it's an action hook, so don't expect it to return something, because nothing cares about what an action hook callback function returns, whereas for filters hooks, you will always see something waiting for the returned result: // Action hook do_action('foo_action'); // Filter hook $bar = ...


0

The solutions seems to be (found in /wp-includes/class-wp-editor): add_filter('the_editor_content', 'YourFunctionName');


1

You could use get_attached_media() function to check if the post has any attached images to it. Also, you use wrong logic operator. Your code would look like this: $attached_images = get_attached_media('image', $post->ID); if ( (get_the_post_thumbnail() == NULL) && empty($attached_images) ) { // show your default image } else { // do nothing, I ...


0

This is how to do it for all post types: add_action( 'do_meta_boxes', 'remove_default_custom_fields_meta_box', 1, 3 ); function remove_default_custom_fields_meta_box( $post_type, $context, $post ) { remove_meta_box( 'postcustom', $post_type, $context ); }


0

The Missing Arguments error disappeared after making a small change to the parameters in the function: function remove_widget_title($title, $instance) to: function remove_widget_title($title, $instance = [])


1

You don’t pass more than argument to that filter, so any callback expecting more than one will not get it. The core calls this filter always like this: $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base ); But you are passing just $instance['title']. Add the missing ...


0

The second argument for the_title is always a post ID. Use it. add_filter( 'the_title', function( $title, $post_id) { $post = get_post( $post_id ); if ( ! $post or 'your_cpt' !== $post->post_type ) return $title; return 'Test ' . $title; }, 10, 2 );


0

I am not entirely sure I understand your project but it sounds to me like you should be using the wp_title filter, instead of the the_title filter. That is fired by the wp_title() function which outputs the page title, not the titles of the posts on the page. Something like: function wpse_change_page_title( $title ) { if(is_page('some_page')) { ...


2

I believe that the page title you are talking about is the title from the page from the main query. the_title() filter (and the_content() filter for that matter) targets all the respective template tags regardless of query. To avoid this, target only the main query and the specific page. You can try the following inside your filter if ( in_the_loop() ...


4

pre_get_posts allows you to alter the query arguments very early on in a request. You can modify anything that would be a valid WP_Query argument, including the LIMIT via the posts_per_page argument. This allows much, much broader range of effects than posts_limits which only allows you to alter one part of the database query SQL. In your case, use ...


4

Note that here you're overriding the paging of the main query, with the posts_limits filter, by using hardcoded values: 'LIMIT 0, 25' where 0 is the offset and 25 is the number of posts to display. So in this case I would just use pre_get_posts with $query->set( 'posts_per_page', 25 ); and we don't have to worry about the paging. If i wanted to ...


0

I was able to solve this by using str_replace. function mp_filter_download( $result ) { $search = '<div style="clear:both;"></div>'; $replacewith = ' '; return str_replace( $search, $replacewith, $result ); } add_filter( 'downloads_shortcode', 'mp_filter_download', 10, 2 );


0

You can use the following SQL query SELECT * FROM wp_posts a, wp_term_relationships b, wp_terms c WHERE a.post_status = 'published' AND a.ID = b.object_id AND b.term_id = c.term_id; This will list all the post that is in the published state and then its terms. You can add limits and offsets to limit the number of records.


0

You would probably get at least equally good performance by simply adding the classes with a filter, and it is certainly neater and closer to the way the WordPress is meant to be modified: function add_classes_wpse_190966($classes) { if (in_array('current-menu-parent',$classes)) { $classes[] = 'active'; } return $classes; } ...


0

If you are using W3 Total Cache or any other caching system make sure it does not cache the feeds. WordPress uses SimplePie for parsing it's feeds. They are many things that are happening at the same time that can cause some confusion. First SimplePie does cache the feeds, I haven't figured yet how to clear it or where it is stored. But you can use this ...


0

You will need to know WordPress hooks and their uses. for list of hooks please find Where can I find a list of WordPress hooks?


0

You hadn't included how had you arrived at this concept, but the whole "presets" branch of logic is pretty strange. Post-filtering vs pre-filtering WordPress filters are de-facto centered on filtering results. Your my_plugin_get_options filter follows that model — the results are produced and offered for modification. Sometimes that is undesirable, what ...



Top 50 recent answers are included