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 | |
function hck_filter_taxonomy_archives( $query_args, $sfid ) { | |
if( $sfid == 509 ) { | |
$query_args = array( | |
'post_type' => 'articles', | |
); | |
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 | |
function hck_filter_taxonomy_archives( $url, $sfid) { | |
if (is_tax('topics')) { | |
$slug = get_queried_object()->slug; | |
$url = site_url() .'/'. get_post_type() .'/'. $slug; | |
} | |
return $url; |
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 | |
function yournamespace_rest_transient_example() { | |
//check for transient first | |
$data = get_transient( 'yournamespace_data_example' ); | |
if ( !empty( $data ) ) { | |
$data = $terms_transient; |
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 | |
function yournamespace_delete_transient( $post_id, $post, $update ) { | |
delete_transient('yournamespace_data_example'); | |
} | |
//{your_post_type} with a custom post type | |
add_action('save_post_{your_post_type}', 'yournamespace_delete_transient', 10, 3); |
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 | |
/*** | |
Stores persisent data as post meta instead of using Transient API | |
@param $post_id int post ID to store post meta for | |
@parm $meta_key str "transient" name | |
@param $update_func str function to update the meta key with a new value | |
@param $expiration time when value should expire |
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 | |
/*** | |
Register custom field for existing endpoint with callback function | |
Endpoint: /wp/v2/your_post_type | |
Note: Could also be a custom endpoint using register_rest_route | |
***/ | |
register_rest_field('your_post_type', 'custom_field_name', 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 | |
/*** | |
Allow a product to be added only once to cart | |
***/ | |
function drw_edd_one_item_checkout( $download_id, $options ) { | |
if ( edd_item_in_cart($download_id) ) { | |
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 | |
/*** | |
Do something with payment data after purchase | |
***/ | |
function drw_api_call_after_purchase( $payment_id ) { | |
$payment_meta = edd_get_payment_meta( $payment_id ); | |