Adding featured image to posts created by a plugin

The quickest and dirtiest way to do this is to add one line to the insert_posts() function, just before the $imported++; line: } add_post_meta( $post_id, ‘raw_import_data’, json_encode( $twitter_raw ) ); // NEW LINE (change 1001 to the image ID): set_post_thumbnail( $post_id, 1001 ); $imported++; } This will obviously disappear if you ever update the plugin. … Read more

Woocommerce getting top level category parent and make all sub categories have the same template and menu

WP native function get_queried_object() can help you to get an ID of a currently displayed term. WooCommerce then includes this handy function: woocommerce_get_term_top_most_parent() (originated here on WPSE btw,) that will get it’s top-level parent term. I haven’t tested the following code but it should provide a good starting point: if ( ‘wedgwood’ == woocommerce_get_term_top_most_parent( get_queried_object()->term_id … Read more

Create Short code dynamically

I cannot comment, I would if I could, but I can’t, please don’t down-vote Could you not just use 1 shortcode with a parameter, e.g. instead of create one for each gallery image-gallery-1,image-gallery-2 etc, you could just use the ID as a parameter: image-gallery 1, image-gallery 2 … Then in your handling function you can … Read more

Woocommerce products per page dropdown

This does not have anything to do with cookies, this is what happends: 1. Visitor goes to page 4/6 wich shows products 40-50 (10 per page) 2. When visitor changes products per page from 10 to 30, he will still be at page 4, when there are only 2 pages (60 products / 30 = … Read more

Best practice when modifying plugins CSS [duplicate]

Any changes you make to the plugin’s stylesheet will be overwritten when you update the plugin. Likewise with an edit to the theme’s stylesheet. Even if you create your own stylesheet and enqueue it via functions.php you will have redo the enqueueing when you update. Of course, if this is a theme (or child theme) … Read more

WP_Table_List and ob_start() memory limit

How often do the results change? I think the results are finally and did not change often (or never). Maybe it is better to use a file caching then using output buffering. Write the results to a file and append a hash or date to the filename as indicator. If the results are updated or … Read more