Correct Syntax for uploading files to custom directory in WordPress

(Update to answer: 05.27.15) What finally worked is using ABSPATH: $folderPath = “/jobtracking/files/standard/{$projID}”; mkdir(ABSPATH.$folderPath, 0755, true); $filename = basename($_FILES[‘Attach_Files’][‘name’]); $filetype = $_FILES[‘Attach_Files’][‘type’]; $datei = “files/standard/{$projID}/{$filename}”; $target_path = ABSPATH.$folderPath . “https://wordpress.stackexchange.com/” . $filename; if(move_uploaded_file($_FILES[‘Attach_Files’][‘tmp_name’], $target_path)) { mysql_query(“INSERT INTO files (files.name, files.project, files.user, files.added, files.datei, files.type, files.folder, files.visible) VALUES(‘{$filename}’, ‘{$projID}’, 5, UNIX_TIMESTAMP(now()), ‘{$datei}’, ‘{$filetype}’, 0, ‘ ‘)”); … Read more

Date when the custom field was added

By default, there are no creation dates associated with custom meta fields. If you check the description, you can see that it is a very simple table of key/value pairs associated with a post ID, plus an auto-increment field. There is no time component at all. The only thing you can do with default functionality … Read more

Get the current page in a call back function

You need the protocol, the host name and the (root relative) request URL. Then stick them together: $scheme=”http” . ( is_ssl() ? ” : ‘s’ ) . ‘://’; $url = $scheme . $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’];

Hide page title

It’s simple: Don’t forget to move add_filter to functions.php file 🙂 <?php /* Template Name: No Title Page */ add_filter( ‘the_title’, function ($title) { return “”;}); ?> <?php get_header(); ?> <div class=”wrapper”> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( ‘content’, ‘page’ ); ?> <?php endwhile; // end of the loop. ?> </div> … Read more

upload images on front by user using form

If all you do is update ACF fields with your form, why not use the built-in function to generate the form? Create a new ACF field for the images, or simply use the Gallery field type, then display the form using acf_form: <?php acf_form(array( ‘post_id’ => ‘new_post’, ‘new_post’ => array( ‘post_type’ => ‘vendre’, ‘post_status’ => … Read more

Load php function with AJAX on modal window

You can’t directly use sendTrailer.php ,wordpress can’t find this custom page directly so you have to specify fully path of that page using get_template_directory() In your ajax function write url : ‘<?php echo get_template_directory(); ?>/sendTrailer.php’

Setting field not saving on front-end

Make the $options variable global by changing the header_add_content() function to the following: function header_add_content() { global $options; $options = get_option(‘header_options’); } add_filter(“the_content”, “header_add_content”); Then declare $options as the global $options on the front-end template before you use it, for example: <p><?php global $options; echo $options[‘txt_mail’]; ?></p>