Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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