Tag Info

New answers tagged

1

Yes, there is a filter for this. The correct filter is wp_mail and is defined in /wp-includes/pluggable.php Line 135 So the code (maybe in your functions.php) should look something like this: function mail_template($args){ ob_start(); require_once (get_template_directory() . '/mail-templates/contacemail.php'); $args['message'] = ...


0

The source of this problem was a mu-plugin that our vendor left in, but should have been removed. Anyway, the lesson here is to always check your plugins.


0

Have you looked at using add_image_size? Check it out here. It will allow you to crop images various ways. It will also allow you to use the standard the_post_thumbnail and pass it your custom image size when you go to output this on the front-end. I also just noticed that you said inside the content. One way would be to take the above function and wrap it ...


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


0

It turns out that some themes disable functions.php for the backend, in order to prevent a complete lockout. The way they do this, is by simply doing an is_admin() check. However, since all AJAX is ran through admin-ajax.php, this returns true, and the theme functions are not loaded. In this particular case (Genesis Framework (theme) with Dynamik website ...


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


0

All I can think is to process the posts at an earlier stage with a Core hook. This is crude, of course, but: function hack_the_post($posts) { foreach ($posts as $p) { $p->post_content .= ' I added this'; } return $posts; } add_action('the_posts', 'hack_the_post'); It is a bit energy intensive but so long as your plugin/theme uses more or less ...


-1

use action="#" or action="<?php echo($_SERVER["PHP_SELF"]);?>" to redirect to same page


0

Try this: <div class="my-metabox"> <!-- This is your metabox HTML --> <-- Add this button somewhere: --> <button id="my-submit" class="button button-primary button-large">Submit</button> </div> Add this JavaScript snippet however you want only to this screen (either by checking the post type and enqueue ...


0

You are using the global $wp_query not your custom query. Either declare yours global too like global $wp_query_archives and then use that in the sm_inline_post_class callback while being aware of the drawbacks of using global variables or do a little work like so: $class = sm_inline_post_class( array(), $my_custom_query ); And then pass $class as the ...


0

Trying @birgire's solution. Is it valid for Wordpress 4.x? I can't add any fot eh preview_post_link or preview_page_link filters. The function jsut doesn't get hit. function bitflower_change_post_link($link, $post) { //replace www part with server1 using the following php function //preg_replace ( patter, replace, subject ) syntax ...


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


0

You are already echoing the data. Just use the_content(): echo '<div class="category-description"><p>',the_content(),'</p></div>'; Please note: those are commas not periods. echo will accept multiple parameters separated by commas and you will not see the odd results you get if you try to concatenate. The above is functionally the ...


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


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


0

I wrote this plugin to do what you're asking - Simply Show Hooks. It shows you where all the action and filter hooks are, inline, in order, on the page you're looking at, and all the functions that have been hooked to them. Hope this helps :)


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


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


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



Top 50 recent answers are included