Exclude a ‘portfolio’ custom category?

Please take a look at this example; $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘movie_genre’, ‘field’ => ‘slug’, ‘terms’ => array( ‘action’, ‘comedy’ ) ), array( ‘taxonomy’ => ‘actor’, ‘field’ => ‘id’, ‘terms’ => array( 103, 115, 206 ), ‘operator’ => ‘NOT IN’ //you must set the … Read more

foreach pagination

Here is the code I used to solve my problem: <?php $url = $_SERVER[“REQUEST_URI”]; $segments = explode(“https://wordpress.stackexchange.com/”, $url); $page = is_numeric($segments[count($segments)-2]) ? $segments[count($segments)-2] : 1; $next = $page + 1; $prev = $page – 1; $issues_per_page = 11; $lastpage = ceil(wp_count_terms( ‘mag’) / $issues_per_page) ; ?> <?php wp_count_terms( ‘mag’ ); ?> <table> <tr> <?php $col … Read more

How do I call comments_template(); from a plugin file?

from the wordpress codex: comments_template(); //Loads the comment template. For use in single Post and Page displays. //Will not work outside of single displays unless $withcomments is set to “1”. my bet is that you need that ->$withcomments thingy <?php global $withcomments; $withcomments = true; comments_template(); ?>

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