make default upload folder year/month/day wordpress without plugin [duplicate]

Here is a similar question. The simplest solution that worked for me was use the upload_dir filter. Place the code below in your functions.php file. function wpcb_upload_dir_filter($uploads){ $day = date(‘d’); $uploads[‘path’] .= “https://wordpress.stackexchange.com/” . $day; $uploads[‘url’] .= “https://wordpress.stackexchange.com/” . $day; return $uploads; } add_filter(‘upload_dir’, ‘wpcb_upload_dir_filter’);

Load a Header in wordpress

You’re really close – get_header_image() returns the URL of the image, whereas header_image() echo’s out the URL. Because you’re setting your style tag in a variable and then echo’ing that, you need to use the function that returns the header image URL – so, like this: $banner=”style=”background-image:url(“. get_header_image() .’);”‘; Using header_image() will, as you found, … Read more

how can I make the search return only single random correct result?

For a relatively small number of posts, you could try the following: /** * Return a single random search result */ add_action( ‘pre_get_posts’, function( \WP_Query $q ) { if( ! is_admin() && $q->is_main_query() && $q->is_search() ) { $q->set( ‘posts_per_page’, 1 ); $q->set( ‘orderby’, ‘rand’ ); } } ); where we modify the main front-end search … Read more

WordPress Media Library

Hi unless you’ve backed up your files there’s no other way to retrieve images except for asking your webhost to see if they have a backup. My host does, and keeps it for 30 days before deleting the backup, so that’s what I’d try first. In future, make sure you back up your sites regularly.

Non Object Notice Error – How to fix please

Replace your code with as mentioned below: public function admin_body_class($classes) { global $wpdb, $post; $screen = get_current_screen(); $status=”parent-“; if( isset( $post->post_parent ) && $post->post_parent > 0 ) { $status=”child-“; } $classes .= ‘ ‘ . $status . $screen->post_type; return $classes; }

Displaying post/page info on a homepage using get_post()

I worked it out, when in the admin area of a page/post you can find the post ID in the browser URL: http://localhost/newsite/wp-admin/post.php?post=1807&action=edit So the previous dev simply uses this page as a ‘parent’, and refers to it as they set $id = get_post(1807); Now the query find posts/pages that a ‘children’ of this page.

wordpress plugin | short code issue

Without seeing your code it is impossible to be sure, but my guess is that you’re echoing the output of your shortcode instead of returning it. function my_shortcode($atts){ //do shortcode logic echo $result; //This is wrong and would do what you describe. } function my_shortcode($atts){ //do shortcode logic return $result; //This is what you should … Read more

save_post hook is not working after changing priority

Remove the hook at its priority, then add your own at the same place. Use the code (as you seem to have) implicitly and all should go well. Without knowing where the hook is added, you’ll want to check on that price as well (plugins_loaded, etc).

Query category name by variable

It seems that you miss some PHP basics? http://php.net/manual/en/language.operators.string.php Anyhow, This $post_categoria = new WP_Query(‘category_name=name-category’); Should become this: $post_categoria = new WP_Query(‘category_name=” . $nisola);