Tag Info

Hot answers tagged

2

You can try using wp_insert_post_data for the task. Something like: function assign_new_post_to_specific_author( $data , $postarr ) { // Where author_ID is the ID of the author you want to assign the new post $data['post_author'] = author_ID; return $data; } add_filter( 'wp_insert_post_data', 'assign_new_post_to_specific_author', '99', 2 ); ...


1

Don't forget that when you are adding a filter it will stay there for all subsequent request. I would suggest you remove the closure and do something like this: function x_example( $input ) { remove_filter( 'posts_where', 'x_example' ); return $input; } add_filter( 'posts_where', 'x_example' ); You will have to do the same thing for the posts_join ...


1

You can achive this using WP Query with meta_query argument as following. $args = array ( 'post_type' => array( 'post' ), // YOUR POST TYPE 'meta_query' => array( array( 'key' => 'country', 'value' => $your_country, // THE COUNTRY TO SEARCH 'compare' ...


1

You have one or two issues here and possible future bugs that you might encounter term in your tax_query should be terms Be carefull with terms having dates as names and especially dates as slugs. This can cause issues and unexpected results if custom permalinks clash or if something falls into the template hierarchy for some reason. Never use the name ...


1

Just run a normal tax_query and set the field parameter to slug in the query. I assume that you already have a way getting the array of slugs (Requires PHP5.4+) $args = [ 'post_type' => 'product', 'posts_per_page' => 12, 'tax_query' => [ [ 'taxonomy' => 'TAXONOMY_NAME', 'field' => ...


1

In most of case, it would bee easier to use a Custom Post Type instead of creating a new table then it can solve you encoding problem because WordPress use unicode


1

You can use publish_post action hook for notifying post author. function wpcs_author_notification( $post_id ) { $post = get_post( $post_id ); $author = get_userdata( $post->post_author ); $message = "Hi " . $author->display_name . ", Your post, " . $post->post_title . " has just been published at " . get_permalink( $post_id ); ...


1

I think that by adding a delay you're not really fixing the issue, you're simply hiding it, until you grow and add more media and servers, so lsyncd will take longer, and you'll have to increase your delay every time. Also what about updating existing posts? People might add media items and update, or add more items to a gallery, you'll have to add delays ...


1

try this $post_id = 11; $post = get_post($post_id); $slug = $post->post_name; <a href="<?php get_site_url(); ?>/abstract/<?php echo $slug; ?>" title="<?php the_title_attribute(); ?>">Abstract</a>



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