Setting a cookie upon specific URL visit

I’ve used this and it works: add_action(‘init’, ‘optin_cookie’, 1); function optin_cookie(){ $currentURL = “https://” . $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’]; if ( $currentURL == ‘https://25dni.si/delovanje-uma/’ ) : setcookie( ‘opt_in’, has_opt_in, time()+31556926, “https://wordpress.stackexchange.com/”); elseif ( $currentURL != ‘https://25dni.si/’ ) : if ( ! isset( $_COOKIE[‘opt_in’] ) ) : endif; endif; } I’m sure there is a much more … Read more

Last updated date function

You can check for your “home page” at the start of your function by using is_home() and/or is_front_page() and just return original content without date. See is_home vs is_front_page function wpb_last_updated_date( $content ) { if ( is_home() || is_front_page() ) return $content; //homepage return content without date // your original function code } Alterantively you … Read more

Handling Body class based on Template

I’m not sure if I understand your question correctly, but… If you want to set body classes based on current page, then you can use this code function my_body_class( $classes ) { if ( is_home() ) { $classes[] = ‘wbody’; } else { $classes[] = ‘gbody’; } return $classes; } add_filter( ‘body_class’, ‘my_body_class’ ); Of … Read more

Inserting a functions output after the content

Your shares_content function directly outputs content, which won’t work if you’re trying to assign the results to a variable or use it in a return statement within another function. You can change it to return the string: function shares_content() { $content = “<div class=”social-shares-container”><a href=”https://www.facebook.com/sharer/sharer.php?u=%s”>Share on Facebook</a></div>”; return sprintf( $content, get_permalink() ); } It’s also … Read more

Php function 301 redirect

There is nothing wrong with wp_redirect part of your code… But… is_page function can’t be used with URL address… You should pass “Page ID, title, slug, or array of such” as stated in documentation.

WordPress upload_mimes not working for front-end uploads of 3D files

Thanks to this thread here, I found this code function fix_wp_csv_mime_bug( $data, $file, $filename, $mimes ) { $wp_filetype = wp_check_filetype( $filename, $mimes ); $ext = $wp_filetype[‘ext’]; $type = $wp_filetype[‘type’]; $proper_filename = $data[‘proper_filename’]; return compact( ‘ext’, ‘type’, ‘proper_filename’ ); } add_filter( ‘wp_check_filetype_and_ext’, ‘fix_wp_csv_mime_bug’, 10, 4 ); which does allow the files to be uploaded through the … Read more

Add Featured image column into wordpress admin on pages AND posts

The reason you’re getting an error is because you’ve got multiple functions with the same name. You have two functions called add_img_column() and two called manage_img_column(). You can’t have two functions with the same name in PHP. You don’t even need two functions though. You can hook the same function into multiple hooks. So this … Read more