Tag Info

New answers tagged

1

Try to replace if ( $url !== 'http://www.mydomain.net/' ) with if ( !is_home() ), which is WP's own function that checks if it's the blog's front page.


0

I solved the problem by moving the following code: $email = $posted_data['email']; $user = get_user_by( 'email', $email ); global $wpdb; $query = 'SELECT code FROM ' . TBL_DISCOUNT_CODES . ' WHERE participant = 0'; $row = $wpdb->get_row( $query ); $wpdb->update( TBL_DISCOUNT_CODES, array( ...


0

Try the save_post hook instead of wp_insert_post_data. It should solve your problem


0

Not sure, but seems maybe $data['post_status'] would be set to 'trash' at that point. If so, then you could just do something like... if ($data['post_status'] == 'trash') { return $data; } ...before the other manipulations. EDIT That code should work then - but needs to be at top of the function, like... public function updatetitle($data) { if ...


0

The code snippet in question is: $check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value ); if ( null !== $check ) return (bool) $check; This filter only allows you to prevent the updating of the metadata for a given type, not to explicitly change the metadata itself. If you want to use this ...


0

WP_Query is an object not an array. Needed to use $query->posts For anyone interested I found a better way to attack this problem. Performing the second query with the OR statements and outputting to an array of post ID's allowed me to filter the original query based off that list.


1

From the comments the remove_filter is called too early before the core add_filter is called. Best way to avoid this is to always remove nd add your filter at the init action add_action('init','wpse163434_init'); function wpse163434_init() { remove_filter..... add_filter..... } This way you are assure that the core had finished initializing and all ...


3

Internally post meta are handled via object cache that is hardly filterable. The only chance to filter post metadata is to use the 'get_post_metadata', but that filter is triggered when meta data are not available, so there is nothing to filter, it was intended to short-circuit the result more than to filter them. So the solution I propose is: launch a ...


1

You can simply use current_filter() WordPress function. http://codex.wordpress.org/Function_Reference/current_filter


1

Note: The reason this doesn't work for the OP is the use of woocommerce, otherwise, so in regards of core WordPress functionality, this should be working as described. Update: I assumed it is about emails on registration. Good thing you specified your needs. WordPress tries - several checks are performed - to add the new user with wp_insert_user - ...


1

Ok, this is actually about the output as you said in your comment. I suppose you know, you can do modification like this: // assumed a single result is returned as string $your_post_meta = get_post_meta( get_the_ID(), 'your_post_meta', true ); // lets add something $your_modified_post_meta = 'My post meta: ' . $your_post_meta; So far so obvious I would ...


0

Hiding by css also affect other post/page types. At least I was able to remove Actions for an specific cpt using this hook add_filter('bulk_actions-edit-mycpt', '__return_empty_array');


0

Well, you could edit the fields when you save the post using the save_post filter. - View Codex Codex Example /** * Save post metadata when a post is saved. * * @param int $post_id The ID of the post. */ function save_book_meta( $post_id ) { /* * In production code, $slug should be set only once in the plugin, * preferably as a class ...


0

To be honest, I had to actually see the source code to get the correct answer for you. The problem with this particular filter is that the $filter part is dynamic and thus you have to know what particular frequency you want to modify. There's a numerous of options: homepage, blogpage, $post_type . '_archive', $post_type . '_single', $c->taxonomy ...


1

To be honest, the function in_the_loop() is what you are looking for: add_filter('the_content', 'custom_content'); function custom_content( $content ){ if( in_the_loop() ){ // My custom content that I add to the_content() } return $content; } What in_the_loop does is, to check if global for $wp_query (that is the main query ...


3

This is merely an addition to @Otto's answer. Just to make it a little bit better understandable. Basically what @Otto is saying, you have to reverse the logic, that means: if you can reliably determine the main query, then you can add - and remove - your hooking into the the_content filter. For example the main query can reliably be recognized at the ...


1

You're using is_main_query() incorrectly. The global is_main_query() function returns true unless the global $wp_query variable has been redefined. There is probably no 100% reliable way to tell, from inside a the_content filter, whether or not the current Loop you're in is the main query or not. The content filter just filters content. It doesn't have any ...


2

You just forgot to return the excerpt for the other post types. Try for example: function do_my_shortcode_in_excerpt( $excerpt ) { if ( 'services' == get_post_type() ) $excerpt = do_shortcode( wp_trim_words( get_the_content(), 55 ) ); return $excerpt; } add_filter( 'get_the_excerpt', 'do_my_shortcode_in_excerpt' );


0

I tried the method above with the saving/updating but didn't worked for me so I went from another approach. I exported the whole wp_posts table, opened it in Sublime and did a regex replace. I used style="*.*?" to find all cases and replaced them with emptyness. Then droped the old table's content and imported the new one. If any one try this method - ...


1

A number of admin interfaces are hardcoded to return the default statuses regardless of what you do. The post status system in WordPress is not exactly fully formed and you'll no doubt encounter bugs. Refer to the edit flow plugin for examples of working around this


0

Try adding the return as well in the else{}, like this: function template_chooser($template) { global $wp_query; $post_type = get_query_var('post_type'); if( $wp_query->is_search && $post_type == 'product' ) { return locate_template('archive-products.php'); } else { $args = array_merge( $wp_query->query, array( 'post_type' => ...


2

If I understand well, you want to append to every post a meta value taken from another post, but the latter need to be dynamic, so not hardcoded in the function. In OP you say the post id is "user-defined". What does it exactly mean? If it is stored somewhere or it is given as query var the simplest solution is moving the code that retrieve the selected ...


2

When two or more filters are hooked to the same filter hook, the conflict is resolved as follows: If the filters are hooked with a priority parameter, the filter with a lowest value for the priority will be executed first. If no priority value is supplied, the default value is taken as 10. If two or more filters are hooked with the same priority, the ...


0

I got it working in the end by using 'template_redirect' and changing the remove_action number from 8 to 1 :) // Remove 'Genesis Co-Authors Plus' author box and 'filed under' from custom post type add_action('template_redirect', 'lf_custom_cpt_display'); function lf_custom_cpt_display() { if ( is_singular( 'local-bite' ) ): { remove_action( ...


0

This question is pretty old, but here's what I came up with for Wordpress 4.0+ Wordpress oembed wants to store the oembed urls on their own line in the database with no other markup. That's the only way it will work. Try pasting this into the "Text" tab of a page or post: <h2>This Video Won't Work:</p> ...



Top 50 recent answers are included