Tag Info

Hot answers tagged

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 ...


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 ...


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 ...


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 ...


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() ...


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 ...


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: ...


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( ...


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

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

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.


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 ...


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 ...


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.


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' );



Only top voted, non community-wiki answers of a minimum length are eligible