Running rmdir function on post save

Add this to your theme’s functions.php file: function wpse202681_save_post_action($post_id, $post_object, $update) { $folder = “/temp/files/”; delFolder($folder); } add_action( ‘save_post’, ‘wpse202681_save_post_action’, 10, 3 ); // + delFolder() function definition You will probably have to alter folder paths depending on your /temp/files/ location. This will execute everytime any post is saved. You can restrict it to only … Read more

How to use theme function in post/page?

Whenever using any WordPress function with get_xyz_etc() make sure you ECHO the function if you want to output the value there: <img class=”first-slide” src=”https://wordpress.stackexchange.com/questions/203434/<?php echo get_template_directory_uri() .”/images/landing-banner.png’; ?>” alt=”First slide”> It will now output the path!

Writing PHP code in pages without issue?

Writing code in a WP post is not a good idea. As czerspalace mentions the easiest solution is to use a Custom Field to paste the code and use a Shortcode to render it in HTML. The post would be like: Any number of shortcodes can be used, just put a unique name for each … Read more

Resize image to specific dimension (X to Y ratio)

If the last parameter $crop is true, then »images will be cropped to the specified dimensions using center positions«, with »(…) an array can specify positioning of the crop area« – this is generally called hard crop. But you have to make sure that the images are big enough to actually crop the size you … Read more

Pagination on Custom Post

When you use WP_Query to get post from database, you must have to use next_posts_link() with max_num_pages parameter for our current query. You can do this as below. <?php next_posts_link(‘More &raquo;’, $packages->max_num_pages) ?> Now your code will become this. I have made above changes in following code. <div class=”eight columns”> <ul> <?php $paged = (get_query_var(‘paged’)) … Read more

Parsing Menu Items and Blog Posts

I’m sure what you’re asking can be done, but there’s a far simpler, significantly easier solution, just register each menu multiple times for each language, and show different menus for different languages. This way you don’t need to figure out how to filter out menu items depending on GET variables, and your pages become more … Read more

WP_OPTIONS table, active_plugins entry [closed]

That entry is a PHP serialized array. The serialize method takes an array and stores it’s value as a string so it can be stored elsewhere – like a database. In the above example, the “s:” entries stand for “string:”. With a serialized array, each element’s data type is represented by a letter (a, s, … Read more