Tag Info

Hot answers tagged

3

The problem with your approach is that woocommerces product category is a custom taxonomy called product_cat. But with cat you are addressing the built-in category. Taxonomies can be addressed with a tax query, simplified example below: function wpse188669_pre_get_posts( $query ) { if ( ! is_admin() && ...


2

The following filter shows only the top-level custom post type items in page attribute dropdowns (in main edit screen and in quick edit). Replace the 'my_custom_post_type' with your custom post type name. function my_test($args) { global $post_type_object; if ( $post_type_object->name == 'my_custom_post_type') { $args['depth'] = 1; } ...


2

Are you calling flush_rewrite_rules at any moment? If you are going to change the slug of a custom post type, you also have to call the flush_rewrite_rules. You can find more documentation here Setting up custom post type archives in WP3.1? Any luck? And here https://codex.wordpress.org/Function_Reference/flush_rewrite_rules


1

You can set the expire date as post meta value. In single.php you can easily show that date by querying the post meta. See update_post_meta() and get_post_meta() Now, the second part of your question is pretty tricky. I can think of 2 solutions. Cron You can use wordpress cron to run at a time interval to check which post has been expired and ...


1

i'm not exactly sure the full context of what you are doing here. there are a number of possible solutions. first is to make sure you are accessing $post as you expect. in other words, make sure it is not being affected by other activity as WordPress builds the page. i don't know if $post contains the object you expect at this point in the flow -- because ...


1

I would just just scrap the function above as there are several bugs in the code and is also not quite effecient. I am actually surpriced that it really works for you. Your best solution here would be to write a complete new function. Here is want we want to do and how we are going to accomplish this Get the current post object on the single post page. ...



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