Skip to content

Instantly share code, notes, and snippets.


Denis Žoljom dingo-d

View GitHub Profile
View wordpress-delete-all.php
* This script will delete everything you have in wordpress.
* I use it only when developing something that requires me to delete everything, e.g. importer.
* You can comment some parts out if you need to quickly delete just posts, or pages or so, but still be very careful!!!
* @author Denis Žoljom (
* @license Free to use at your own risk
dingo-d / pagination.php
Last active Dec 26, 2015
Custom made pagination for wordpress
View pagination.php
global $wp_query;
$total_pages = $wp_query->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
$permalink_structure = get_option('permalink_structure');
$format = empty( $permalink_structure ) ? '?paged=%#%' : 'page/%#%/';
echo '
<section id="pagination" class="clearfix">
<div class="container">
View add-pages-post-metabox.php
add_action('admin_init', 'add_meta_boxes', 1);
function add_meta_boxes() {
add_meta_box( 'repeatable-fields', esc_html__('Related Articles', 'mytheme'), 'my_related_articles_meta_box_display', 'post', 'normal', 'high');
function my_related_articles_meta_box_display() {
dingo-d / menu-walker.php
Last active Jan 19, 2016
A menu walker for adding sidebars in menu. The megamenu needs to be handled by javascript (or in any other way)
View menu-walker.php
// Allow HTML descriptions in WordPress Menu
remove_filter( 'nav_menu_description', 'strip_tags' );
function my_plugin_wp_setup_nav_menu_item( $menu_item ) {
if ( isset( $menu_item->post_type ) && 'nav_menu_item' == $menu_item->post_type) {
$menu_item->description = apply_filters( 'nav_menu_description', $menu_item->post_content );
dingo-d / header_layout.php
Created Jan 20, 2016
A header layout with AJAX login and register forms (buttons) a part of Header AJAX login/register gist (1)
View header_layout.php
<header id="main_header" class="clearfix">
<div class="top_bar">
<div class="container">
<div class="ajax_login">
<form id="login" action="login" method="post">
<h1><?php esc_attr_e('User login','yourtheme') ?></h1>
<p class="status"></p>
<input id="username" type="text" name="username" placeholder="<?php esc_attr_e('Username','yourtheme') ?>">
<input id="password" type="password" name="password" placeholder="<?php esc_attr_e('Password','yourtheme') ?>">
<div class="forgotten_box">
dingo-d / functions.php
Last active Jan 20, 2016
A part of the functions.php file that is used to log in or register user via AJAX. Part of Header AJAX login/register gist (2)
View functions.php
/********* AJAX Login ***********/
function yourtheme_ajax_login_init(){
wp_register_script('ajax-login-script', get_template_directory_uri() . '/js/ajax-login-script.js', array('jquery') );
wp_localize_script( 'ajax-login-script', 'ajax_login_object', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
dingo-d / ajax-login-script.js
Last active Jan 20, 2016
A javascript file that handles AJAX calls and on click events for AJAX log in and register. Part of Header AJAX login/register gist (3)
View ajax-login-script.js
jQuery(document).ready(function($) {
"use strict";
// Show the login dialog box on click
$('a#show_login').on('click', function(e){
dingo-d / ajax-login.css
Last active Jan 20, 2016
Unfinished .css file for AJAX log in and register. Part of Header AJAX login/register gist (4)
View ajax-login.css
/*------------------------ AJAX login -------------------------*/
text-align: right;
.top_bar .ajax_login{
display: inline-block;
margin-right: 10px;
View custom-registration-forms.php
/********* Custom Registration Form ***********/
add_action( 'register_form', 'travelnews_register_form' );
if (!function_exists('travelnews_register_form')) {
function travelnews_register_form() {
$first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( $_POST['first_name'] ) : '';
$last_name = ( ! empty( $_POST['last_name'] ) ) ? trim( $_POST['last_name'] ) : '';
dingo-d / post_order_customizer.php
Created Feb 11, 2016
A code to put in your customizer.php and in your functions.php of the wordpress to order your home and category posts
View post_order_customizer.php
The below code goes in customizer.php of your theme
SECTION: Post order on home page and index pages