Skip to content

Instantly share code, notes, and snippets.

@dinolatoga
dinolatoga / related-posts.php
Last active December 20, 2015 04:09 — forked from jtallant/jt-related-posts.php
Get WordPress Related Posts by tags if available and category if not
@dinolatoga
dinolatoga / gist:6025880
Created July 18, 2013 00:51
Add admin separator to admin menu
add_action( 'admin_init', 'add_sep' );
function add_sep() {
if ( ! is_admin() )
return false;
global $menu;
$sep = $menu[4]; // that's the default separator
$pos = 6; // change it for the desired position
$menu = array_merge(
function add_admin_menu_separator($position) {
global $menu;
$index = 0;
foreach($menu as $offset => $section) {
if (substr($section[2],0,9)=='separator')
$index++;
if ($offset>=$position) {
$menu[$position] = array('','read',"separator{$index}",'','wp-menu-separator');
break;
}
@dinolatoga
dinolatoga / gist:6004917
Last active January 21, 2021 07:34
Programmatically Create Pages/Posts in WordPress. Personally modified to work properly. Source: http://advent.squareonemd.co.uk/programmatically-create-a-wordpress-page-post-or-custom-post-type/
<?php
// Helper Functions
/**
* Programmatically creates a WordPress post based on the incoming parameters.
*
* Note: This function may need some additional work if you're dealing with non-English languages.
*
* @param string $title The title of the page as presented to the users
* @param string $slug The slug used to access the page via the URL