Skip to content

Instantly share code, notes, and snippets.

View spacetrack's full-sized avatar

Björn Winkler spacetrack

  • Gröbenzell, Munich, Germany
View GitHub Profile
#!/bin/bash
echo $#
this_date=`date +"%Y-%m-%d"`
this_time=`date +"%H:%M:%S"`
if [ $# -eq 1 ]
then
this_date=`date +"%Y-%m-%d"`
this_time=${1}
// always exclude the first story from index pages!
if (!function_exists('archive_exclude_first_post')) {
function archive_exclude_first_post($query)
{
if (is_admin() || !is_archive() || !$query->is_main_query()) {
return;
}
$offset = 1;
$posts_per_page = get_option('posts_per_page');
<?php
class EvalFileWithArgs_Command extends WP_CLI_Command {
/**
* Load and execute a PHP file after loading WordPress.
*
* ## EXAMPLES
*
* wp eval-file-with-args my-code.php arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9
<?php
$mymenu = wp_get_nav_menu_object('Main Navigation Menu');
$menuID = (int) $mymenu->term_id;
$myPage = get_page_by_title('About Us');
itemData = array(
'menu-item-object-id' => $myPage->ID,
'menu-item-parent-id' => 0,
'menu-item-position' => 2,