What is this code in my theme’s functions.php? if (isset($_REQUEST[‘action’]) && isset($_REQUEST[‘password’])

Your website has been hacked. This is malicious code that gets triggered from the outside, loading more malicious content from ‘www.dolsh.cc’ domain. If the content comes back after you remove it, then you have hacked files somewhere else that will automatically rewrite functions.php any time page is loaded. You need to find and clean up … Read more

How to get a variable number of posts per post type on the main loop?

If you are still looking for an alternative that may be faster this may help you: <?php function customBlogFeed() { // The Query $the_query = new WP_Query( array ( ‘post_type’ => array( ‘post’, ‘page’, ‘movie’, ‘book’), ‘posts_per_page’ => ‘6’ ) ); //Your post_type array is a list of random post_types. You can add whatever you’d … Read more

Return $post_id when DOING_AUTOSAVE?

The ‘save_post’ action was added to core in 2.0, and has always been an action. Looking through the current autosave procedures, it doesn’t appear to call the ‘save_post’ action directly at any time. So the short answer is, no. There is no reason, and has never been any reason, to return any value on this … Read more

Include WP_Query in my own PHP file?

Load WordPress in custom PHP Script: You need to load essential WordPress core functionality in your custom PHP script for WP_Query to work properly. For example, let’s say you have a custom PHP file named my-cron.php and WordPress is installed in the web root, like this: public_html/ index.php my-cron.php <– wp-load.php wp-settings.php … wp-admin/ wp-content/ … Read more

WordPress Internal @ Mentions

This is a little tricky because sanitize_user allows spaces in usernames, meaning it difficult to avoid grabbing the whole phrase ‘@johndoe said that … ‘ as opposed to just the actual username ‘@johndoe’ and you have no separator at the end that would help. To avoid that I imposed a requirement that spaces in the … Read more

Upload Multiple Files With media_handle_upload

here if you use custom template past this in the begining <?php if( ‘POST’ == $_SERVER[‘REQUEST_METHOD’] ) { if ( $_FILES ) { $files = $_FILES[“my_file_upload”]; foreach ($files[‘name’] as $key => $value) { if ($files[‘name’][$key]) { $file = array( ‘name’ => $files[‘name’][$key], ‘type’ => $files[‘type’][$key], ‘tmp_name’ => $files[‘tmp_name’][$key], ‘error’ => $files[‘error’][$key], ‘size’ => $files[‘size’][$key] ); … Read more

What is the meaning of %s, %1$s etc.? [closed]

This is really more of a general PHP programming question and might get closed for that reason. But before that happens, let’s see if I can’t clear some of this up for you. Those strings that start with % signs are in “printf format”. For example, %2$s translates to “replace this token with the second … Read more

Best collection of code for your .htaccess file [closed]

These are 3 snippet for better performance, regarding Yahoo! rules: Disable Etags: Header unset ETag FileETag None Add expire headers: <FilesMatch “\.(ico|jpg|jpeg|png|gif|js|css|swf)$”> Header set Expires “Tue, 16 Jun 2020 20:00:00 GMT” </FilesMatch> Or ExpiresActive On ExpiresByType text/html “access plus 1 day” ExpiresByType image/gif “access plus 10 years” ExpiresByType image/jpeg “access plus 10 years” ExpiresByType image/png … Read more

How to display SQL query that ran in query?

Hi @Keith Donegan: If I understand your question correctly I think this is what you are looking for? <?php echo $GLOBALS[‘wp_query’]->request; ?> $wp_query is a global variable that contains the current query run by the loop. If you run the above code anytime while the loop is still active or even right after the loop … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)