Skip to content

Instantly share code, notes, and snippets.

View danielpataki's full-sized avatar

Daniel Pataki danielpataki

View GitHub Profile
@danielpataki
danielpataki / 2014-first-line.php
Last active August 7, 2018 13:50
WordPress Coding For Beginners
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
@danielpataki
danielpataki / basic-function.php
Last active April 4, 2019 19:00
Adding Theme Options With The Customization API
add_action( 'customize_register' , 'my_theme_options' );
function my_theme_options( $wp_customize ) {
// Sections, settings and controls will be added here
}
@danielpataki
danielpataki / latestposts-control.php
Last active April 29, 2020 10:16
Custom Theme Customization Controls
$wp_customize->add_control(
new WP_Customize_Latest_Post_Control(
$wp_customize,
'featpost_control',
array(
'label' => __( 'Select A Featured Post', 'mytheme' ),
'section' => 'header_section',
'settings' => 'featured_post',
'post_type' => 'page'
)
@danielpataki
danielpataki / alt-cron.php
Last active November 14, 2019 02:22
WordPress Config File
define( 'ALTERNATE_WP_CRON', true );
@danielpataki
danielpataki / ajax-action.php
Last active March 15, 2018 16:22
Ajax in WordPress
add_action( 'wp_ajax_button_click', 'user_clicked' );
function user_clicked() {
update_user_meta( get_current_user_id(), 'clicked_link', 'yes' );
wp_redirect( $_SERVER['HTTP_REFERER'] );
exit();
}
@danielpataki
danielpataki / functions.php
Last active March 25, 2018 15:30
Child Themes Article
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :private_network, ip: "192.168.77.77"
config.vm.provision :shell, :path => "install.sh"
#!/bin/bash
# Setup Variables
DBNAME=checker
DBUSER=root
DBPASS=root
DBHOST=localhost
DBPREFIX=9239jej9md_
URL=checker
@danielpataki
danielpataki / wp-cli.sh
Created November 24, 2014 18:56
W-CLI Script
#!/bin/bash
# Setup Variables
DBNAME=blog
DBUSER=root
DBPASS=root
DBHOST=localhost
DBPREFIX=9239jej9md_
URL=http://blog.local
@danielpataki
danielpataki / title-tag.php
Created November 27, 2014 13:52
Title Tag Support
function theme_slug_setup() {
add_theme_support( 'title-tag' );
}
add_action( 'after_setup_theme', 'theme_slug_setup' );
if ( ! function_exists( '_wp_render_title_tag' ) ) :
function theme_slug_render_title() {
echo '<title>' . wp_title( '|', false, 'right' ) . "</title>\n";
}
add_action( 'wp_head', 'theme_slug_render_title' );