Change CSS for logged in users

You need to use the body_class(): http://codex.wordpress.org/Function_Reference/body_class If you use the function body_class() you can set on your css like this: .example { display: none; } .logged-in .example { display: block }

What does this code do? (Injected code hacked)

It gets code from a remote location (http://www.linos.cc/code.php) and stores it within a temporary file using sys_get_temp_dir() – http://php.net/manual/en/function.sys-get-temp-dir.php – and then creates a wp-tmp.php file with the before-mentioned code within your WordPress installation in the following locations: /wp-includes/wp-tmp.php and /wp-content/themes/your-theme-name/wp-tmp.php The code that’s stored in this file (http://www.linos.cc/code.php) appears to append content to your … Read more

WordPress function saves a post twice and updates all posts

It duplicate because when you run the wp_update_post(), it will use the wp_insert_post() function and the action save_post will run again. please use the filter wp_insert_post_data to filter the value before save. https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data Example: function wpse309780_filter_post_data($data , $postarr) { $data[‘post_name’] = wp_count_posts( ‘post’ )->publish; return $data; } add_filter( ‘wp_insert_post_data’, ‘wpse309780_filter_post_data’ );

How can this crude function be improved?

function admin_trim_category_description( $terms, $taxonomies ){ if( ‘category’ != $taxonomies[0] )return $terms; $whatever_categories = array(‘category1’, ‘hidden’, ‘category2’, ‘category3’); foreach( $terms as $key => $term) if(!in_array($terms[$key]->name, $whatever_categories)) $terms[$key]->description = strip_tags(substr( $term->description, 0, 75 )).”…”; else unset($terms[$key]); return $terms; }

Functions.php Problem

I’ve seen in the pastebin the problem and merged the whole code together again. Put this first part completely into your functions.php. /** * Display previous image link that has the same post parent. * * @since 2.5.0 * Original version in /wp-include/media.php * @param string $size Optional, default is ‘thumbnail’. Size of image, either … Read more

Getting comment count per post not working

Try this: <?php $popular = new WP_Query(‘orderby=comment_count&posts_per_page=5’); ?> <?php while ($popular->have_posts()) : $popular->the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/108038/<?php the_permalink(); ?>”><?php the_title(); ?></a> has <?php comments_number( ‘no responses’, ‘one response’, ‘% responses’ ); ?>.</li> <?php endwhile; ?> From the codex.

Conditional functions.php on page template

You can make use of the conditional tag is_page_template() This Conditional Tag allows you to determine if you are in any page template. Optionally checks if a specific Page Template is being used in a Page. This is a boolean function, meaning it returns either TRUE or FALSE. You can try something like if( is_page_template( … Read more