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 | |
/* | |
Plugin Name: CPT Without Slug | |
Description: A test plugin to register a CPT without slug | |
Author: David Mårtensson | |
Version: 0.0.4 | |
Author URI: http://feedmeastraycat.net/ | |
*/ | |
add_action( 'init', 'mycpt_init' ); |
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 | |
add_action('woocommerce_order_actions', 'my_woocommerce_order_actions', 10, 1); | |
function my_woocommerce_order_actions($actions) { | |
$actions['my_action'] = "Do my action"; | |
return $actions; | |
} | |
add_action('woocommerce_order_action_my_action', 'do_my_action', 10, 1); | |
function do_my_action($order) { | |
// Do something here with the WooCommerce $order object |
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 | |
add_rewrite_rule('english/news/([^/]+)(/[0-9]+)?/?$', 'index.php?english=$matches[1]&page=$matches[2]', 'top'); | |
add_rewrite_rule('english/press/press-releases/([^/]+)(/[0-9]+)?/?$', 'index.php?english=$matches[1]&page=$matches[2]', 'top'); | |
flush_rewrite_rules(); |
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 | |
$lq = new WP_Query(array('posts_per_page' => 10)); | |
if ( $lq->have_posts() ): while ( $lq->have_posts() ): $lq->the_post(); ?> | |
<?php the_time('Y-m-d') ?> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br> | |
<?php endwhile; endif; | |
wp_reset_postdata(); | |
?> |
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 | |
/** | |
* Display archive links based on type and format. Uses the built in wp_get_archives() but with | |
* added filters to display archive only for a specific year, month or day | |
* @param string|array $args Optional. Override defaults. | |
* @param null|int $year Specify year for archive | |
* @param null|int $month Specify month for archive | |
* @param null|int $day Specify day for archive | |
* @return string|void Return or echo depending on "echo" argument | |
* @author David Mårtensson <[email protected]> |
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 | |
if (!function_exists('get_post_id_by_meta_key_and_value')) { | |
/** | |
* Get post id from meta key and value | |
* @param string $key | |
* @param mixed $value | |
* @return int|bool | |
* @author David Mårtensson <[email protected]> | |
*/ | |
function get_post_id_by_meta_key_and_value($key, $value) { |