How to create a custom button for the visual editor that adds 4 non-breaking spaces? (plugin or simple code)

I already demonstrated how you can achieve such thing in this question but I can explain it here again with your request. I have tested this in WordPress 3.5 and it works elegantly. To avoid this answer being the length of a thesis, I have added comments in all codes to help you understand what … Read more

how to group custom post types

The filter Inside /wp-admin/menu.php, you’ll find this filter at the end of the “add css classes”-loop: apply_filters( ‘add_menu_classes’, $menu ) The function The following code attaches the right classes to the first and previous elements. It also adds the separator in between. If you need to add another separator to the end/after your group, you’ll … Read more

Create custom [sourcecode] shortcode, the right way?

You’re asking about X, but I’ll answer with Y. IMHO, there are too many exceptions to handle to grant another solution. SyntaxHighlighter Evolved has the following Pro Tip (strong, uppercase, in the original): TIP: Don’t use the Visual editor if you don’t want your code mangled. TinyMCE will “clean up” your HTML. Not only that, … Read more

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

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

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