Skip to content

Instantly share code, notes, and snippets.

@brentini
brentini / gist:031153eddaff504a6551cbd436262470
Last active March 23, 2018 21:32 — forked from yusn/gist:76d91a8befa70fb0187b2427de4f5a92
A base for a functions.php for a WordPress theme #wordpress
<?php
/**
* @package WordPress
* @subpackage Theme_Name
* @since Theme Name 1.0
*/
// replace "themename" with the theme slug
// load javascript on initialization
@brentini
brentini / gist:701aef66da35f0f1073f526db5980f90
Last active March 23, 2018 21:32 — forked from yusn/gist:76d91a8befa70fb0187b2427de4f5a92
A base for a functions.php for a WordPress theme #wordpress
<?php
/**
* @package WordPress
* @subpackage Theme_Name
* @since Theme Name 1.0
*/
// replace "themename" with the theme slug
// load javascript on initialization
@brentini
brentini / functions.php
Last active March 23, 2018 21:32 — forked from sudipbd/functions.php
WordPress remove empty <p> #wordpress
/**
* Remove empty paragraphs created by wpautop()
* @author Ryan Hamilton
* @link https://gist.github.com/Fantikerz/5557617
*/
function remove_empty_p( $content ) {
$content = force_balance_tags( $content );
$content = preg_replace( '#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content );
$content = preg_replace( '~\s?<p>(\s|&nbsp;)+</p>\s?~', '', $content );
return $content;
@brentini
brentini / functions.php
Last active March 23, 2018 21:33 — forked from amitkolloldey/functions.php
Enqueue Scripts And Styles In Wordpress #wordpress
<?php
/**
* Enqueue scripts and styles.
*/
function balihomes_scripts() {
wp_enqueue_style( 'balihomes-fontawesomestyle', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
wp_enqueue_style( 'balihomes-bootstrapstyle', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
wp_enqueue_style( 'balihomes-style', get_stylesheet_uri() );
wp_enqueue_style( 'balihomes-stylemain', get_template_directory_uri() . '/css/style.css');
@brentini
brentini / template-homepage.php
Last active March 23, 2018 21:33 — forked from amitkolloldey/template-homepage.php
Custom Post Query in Wordpress #wordpress
<?php
/*
* Template Name: Homepage
*/
get_header();?>
<?php
global $post;
$args = array( 'posts_per_page' => 24, 'post_type'=> 'villa', 'orderby' => 'menu_order', 'order' => 'ASC' );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post);
@brentini
brentini / header.php
Last active March 23, 2018 21:33 — forked from reneeHS/header.php
header.php for Wordpress #wordpress
<?php
/**
* Flatbase by NiceThemes.
*
* The Header for our theme.
*
* Displays all of the `<head>` section and everything up till `<div id="container">`
*
* @package Flatbase
* @author NiceThemes <hello@nicethemes.com>
@brentini
brentini / ga-tracking-wp.php
Last active March 23, 2018 21:33 — forked from IacopoC/ga-tracking-wp.php
Google analytics tracking code snippet in functions.php WordPress #wordpress
<?php add_action('wp_head', 'add_google_analytics');
function add_google_analytics() {
// Insert your GA code here
} ?>
@brentini
brentini / social-share.php
Last active March 23, 2018 21:33 — forked from cinghaman/social-share.php
Create your own social share buttons (use it for WordPress or simple html sites) #wordpress
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<?php
global $post;
$post_url = get_permalink();
$post_title = str_replace( '', '%20', get_the_title() );
$post_thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post ->ID ), 'full' );
//share URL's
$twitter_url = 'https://twitter.com/intent/tweet?text='.$post_title.'&amp;url='.$post_url.'&amp;via=twitter_id';
@brentini
brentini / reorder-admin-menu.php
Last active March 23, 2018 21:34 — forked from RadGH/reorder-admin-menu.php
Reorganize a specific set of menu items in the WordPress admin dashboard. Also create a new separator and ACF options page, and move those too. #wordpress
<?php
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Add a menu separator to the admin dashboard. This will be positioned within axe_reorder_admin()
*/
function axe_admin_menu_separator() {
global $menu;
$menu[] = array(
@brentini
brentini / child-theme.php
Last active March 23, 2018 21:34 — forked from edward-jimenez/child-theme.php
WordPress recommended method for child theme creation #wordpress
<?php
/*
In your functions.php file on the child theme, enter the following code
*/
function prefix_theme_enqueue_styles() {
$parent_style = 'parent-style'; // style.css of the parent theme
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',