Skip to content

Instantly share code, notes, and snippets.

@mustafauysal
Last active June 1, 2016 23:13
Show Gist options
  • Save mustafauysal/dd1be55bf71db0f899641041de395280 to your computer and use it in GitHub Desktop.
Save mustafauysal/dd1be55bf71db0f899641041de395280 to your computer and use it in GitHub Desktop.
Ornek WP-CLI komutu
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( defined( 'WP_CLI' ) && WP_CLI ) {
class WPH_CLI_Command extends WP_CLI_Command {
function __construct() {
}
function son_yazilar( $args, $assoc_args ) {
if ( ! ( $count = $assoc_args['count'] ) ) {
$count = 10;
}
$args = array(
'numberposts' => $count,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish',
'suppress_filters' => true,
);
$recent_posts = wp_get_recent_posts( $args, OBJECT );
foreach ( $recent_posts as $post ) {
$title = str_pad( $post->post_title, 30, "." );
echo WP_CLI::colorize( "%b$title%n " ) . "\n";
}
}
}
WP_CLI::add_command( 'getir', 'WPH_CLI_Command' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment