Skip to content

Instantly share code, notes, and snippets.

@eminozlem
eminozlem / add_drop_caps.php
Created January 12, 2021 05:07 — forked from strangerstudios/add_drop_caps.php
Filter to add drop caps to first letter of blog posts in WordPress. Add to your active theme's functions.php.
/*
Drop cap first letter of each post.
*/
function add_drop_caps($content)
{
global $post;
//only posts
if(!empty($post) && $post->post_type == "post")
{
@eminozlem
eminozlem / customroutes.php
Created May 23, 2018 04:32 — forked from samhernandez/customroutes.php
A simple class to add custom routes to Wordpress.
<?php
/**
* A class to create simple custom routes.
*
* Example usage:
*
* $theme_routes = new CustomRoutes();
* $theme_routes->addRoute(
*
@eminozlem
eminozlem / custom-queries.php
Created May 16, 2018 20:07 — forked from carlodaniele/custom-queries.php
An example plugin showing how to add custom query vars, rewrite tags and rewrite rules to WordPress
<?php
/**
* @package Custom_queries
* @version 1.0
*/
/*
Plugin Name: Custom queries
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin
Author: Carlo Daniele
@eminozlem
eminozlem / install-wp-plugins.php
Created April 20, 2018 22:09 — forked from squarestar/install-wp-plugins.php
Programmatically install and activate wordpress plugins
<?php
/**
* Programmatically install and activate wordpress plugins
*
* Usage:
* 1. Edit the $pluginSlugs array at the beginning of this file to include the slugs of all the
* plugins you want to install and activate
* 2. Upload this file to the wordpress root directory (the same directory that contains the
* 'wp-admin' directory).
* 3. Navigate to <your-domain-wordpress-root>/install-wp-plugins.php (If wordpress is installed
@eminozlem
eminozlem / gist:84c07a9834aed2062f63
Last active August 29, 2015 14:27 — forked from nickkoskowski/gist:2fb00a84b2be7f91cb30
Get a random post link from WP database using query
<?php
function get_random_post_link() {
$args = array(
'orderby' => 'rand',
'posts_per_page' => '1',
);
$wp_query = new WP_Query( $args );
if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();