Tag Info

Hot answers tagged

3

For custom post types, use the post_type_link filter just a you would use the post_link filter for post post type posts


3

Here's one experimental idea: Assume we got: post A with the custom field location1 as UK - London post B with the custom field location2 as France - Paris post C with the custom field location3 as USA - New York Then we could use, for example: $args = [ 'meta_query' => [ 'relation' => 'OR', [ 'key' ...


3

Reviewing the MySQL string functions, it looks like you could use the SUBSTRING_INDEX() function: ORDER BY SUBSTRING_INDEX( p.post_title, ' ', -1 ) {ASC|DESC} LIMIT 1 to order by the last word of the post title. You could test this method within your orderby filters. Example: Prev/Next CPT - ordered by last word in post title This is an example how ...


2

I don't think that there is a much smarter way to write this code in a procedural style, so basically your code looks okay. But there's a logic error in your body_class_before_header() function which might cause the issue: If the conditional block is not executed, the function will return NULL but as it is a callback on a filter it should always return at ...


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

get_the_content do not apply the_content filter. You have to apply it after receiving contents like following <?php apply_filters('the_content',get_the_content( $more_link_text, $stripteaser, $more_file )) ?> It is also detailed at the bottom of codex page


1

Just use the the_title filter to hook into the title content and work with that. add_filter( 'the_title', function( $title ) { // Manipulate the $title as you want and then return that. // You can add test conditions such as 'is_main_query' // (https://codex.wordpress.org/Function_Reference/is_main_query) return $title; } );


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



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