how to make nsfw post with thumbanil

get_post_meta is your friend: if ( has_post_thumbnail() ) { if ( ‘yes’ == get_post_meta( $post->ID, ‘NFSWEG’, true ) ) { echo ‘<img src=”https://wordpress.stackexchange.com/questions/82422/YOUR-IMAGE-HERE”>’; } else { the_post_thumbnail( array( 400, 400, true ), array( “class” => “aligncenter featured_image” ) ); } }

How do I apply/target CSS to a specific user role or roles?

If you’re looking for a way to add the roles into the body class, like here: <body class=” … role-administrator role-jedi role-knight … “> then you could try the following: add_filter( ‘body_class’, function( $classes ) { if( is_user_logged_in() ) { $classes = array_merge( (array) $classes, array_map( function( $class ) { return ‘role-‘ . $class; // … Read more

Best way to use ajax front-end?

Never ever use your theme/plugin files directly for ajax calls, always use admin-ajax.php. This is the only recommended way of doing ajax to ensure maximum compatibility with wordpress (including future versions) & 3rd party plugins/themes The best/easiest way depends on the situation & is debatable but i would ask you to use admin-ajax.php even if … Read more

Is it secure to use admin-ajax.php in front?

I would like to know if it is secure to use admin-ajax.php for your ajax requests on the front. There is nothing fundamentally insecure about using it for AJAX requests as a protocol. So is it secure? That question makes little sense, in the same way that “Is a coin flip secure?” doesn’t make a … Read more

Fullscreen Video/GIF Intro

The following code uses HTML5 Video, with the muted & autoplay attributes set. It takes the video, which I uploaded through the media gallery and displays it fullscreen. I’m using a script that detects when the video is done playing, then it fades out and is removed from the DOM. HTML <div class=”fullscreen-bg”> <video muted … Read more

Add script into front from my plugin

Use wp_enqueue_scripts and admin_enqueue_scripts actions to enqueue your scripts: // for front end add_action(‘wp_enqueue_scripts’, array(&$this, ‘load_my_scripts’)); // for back end add_action(‘admin_enqueue_scripts’, array(&$this, ‘load_my_scripts’)); Also pay attention that it is bad practice to load your scripts on all pages of the site. Load your script only if need be: // … function load_my_scripts() { if ( … Read more

Redirect after delete post in Frontend

I got a little bit more into this topic and found this solution which works perfect for me. 1 Add this code to functions.php: // Delete post function delete_post(){ global $post; $deletepostlink= add_query_arg( ‘frontend’, ‘true’, get_delete_post_link( get_the_ID() ) ); if (current_user_can(‘edit_post’, $post->ID)) { echo ‘<span><a class=”post-delete-link” onclick=”return confirm(\’¿Are you sure to delete?\’)” href=”‘.$deletepostlink.'”>Borrar</a></span>’; } } … Read more