This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Assign name as title before save when post type is company_personnel. | |
* | |
* Instruction of use: | |
* ------------------ | |
* you can place this eg. in your themes functions.php | |
* | |
* Use case: | |
* -------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public static function get_template($template, $variables = array()) { | |
// Pass variables as a key-value array: array('varname' => 'varvalue') | |
// and conditionally check for them in templates like this: | |
// $varname = !empty($varname) ? $varname : NULL | |
foreach ($variables as $key => $value) { | |
// Create variables from parameters | |
${$key} = $value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Setup $post | |
glopal $post; | |
// Store current post ID | |
$current_post_id = $post->ID; | |
// Note the slash here refers to global namespace. | |
$children = new \WP_Query( | |
array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Reorder WordPress User table by user ID | |
* | |
* @param object $query Instance of WP_User_Query | |
* @return object $query Altered instance of WP_User_Query | |
*/ | |
function my_custom_order_users_by_id( $query ) { | |
// Check that we are in admin otherwise return |