Is it possible to automatically publish a post once a woo-commerce product is published?

WC products are posts themselves, so you could use: add_action(‘publish_post’, ‘wpse_publish_post_with_product’); Within the new function, you’d have a check for post_type. If the post_type that was just published is a WC product, then grab the image and description from that post, and use wp_insert_post() to publish a Post with the same info. Side note: I’m … Read more

How include css class based on post ( in loop ) slug?

The error you get is produced by $slug = get_post( $post )->post_name; because there is no post_name on a 404 page. So, to prevent this error you must structure the function in a way it doesn’t get to this line when it is called on a 404-page. Like this: add_filter (‘post_class’, ‘fl_pages_bodyclass’); add_filter (‘body_class’, ‘fl_pages_bodyclass’); … Read more

get_previous_post() while accounting for sticky posts

Ok, this might be overcomplicating things a bit, but at least it should work (untested). Just call the function like so get_adjacent_without_sticky( get_the_ID(), true); // get previous post get_adjacent_without_sticky( get_the_ID(), false); // get next post This could have been solved easily, if get_previous_post() allowed for an ID to pass and not only run it in … Read more

Displaying list of posts in category page

One option would be to just replace category template with another file from the plugin using category_template filter: function change_category_template( $template ) { $category_template = plugin_dir_path( __FILE__ ) . ‘new-category.php’; return $category_template; } add_filter( ‘category_template’, ‘change_category_template’, 999 ); So, in the new file you could have the structure you want. The main problem is that … Read more

How can I get rid of the automatically generating tags?

If you use a child theme, just add this function to your functions.php file: add_action( ‘after_setup_theme’, ‘foobar_setup’, 11 ); function foobar_setup() { global $editor_styles; $editor_styles = array(); } This works for me for details follow below links which I used as source of this solution : This post and another one

Using system date format

Calling get_the_date( get_option(‘date_format’) ); will return the exact same value as get_the_date(); this is because by default if a date format is not specified when the function is called it will use get_option(‘date_format’); as can be seen from the following snippet taken from the get_the_date() function itself: if ( ” == $d ) { $the_date … Read more

How to set post status to Delete?

You can move the post to Trash before you save it or publish: Or you can do it later, from the post list: Later you can empty Trash or it will automatically delete everything from Trash what is older than a month.

Separate Content from gallery (custom post type)

You can do something like this <?php get_header(); ?> <section id=”content”> <div class=”container”> <?php get_template_part(‘inc/page-title’); ?> <div class=”row”> <?php if (have_posts()) : ?> <?php /* Start the Loop */ ?> <?php while (have_posts()) : the_post(); ?> <div class=”col-sm-7 post-thumb large-thumbnail”> <?php the_post_thumbnail(‘model-full’, array( ‘class’ => “img-responsive” )); ?> </div> <div class=”col-sm-5 entry-content profile”> <?php $properties … Read more