Skip to content

Instantly share code, notes, and snippets.

View ideag's full-sized avatar

Arūnas Liuiza ideag

View GitHub Profile
<?php
add_filter('aioseop_robots_meta','klausk_noindex');
function klausk_noindex($string) {
global $wp_query;
if ($wp_query->is_category && $wp_query->query_vars['cat']==1) {
$string = str_replace('noindex','index',$string);
}
return $string;
}
?>
@ideag
ideag / jsfiddle-oembed.php
Last active March 18, 2023 00:25 — forked from ninnypants/gist-oembed.php
oEmbed JSFiddle links into WordPress posts
<?php
/*
Plugin Name: JSFiddle oEmbed
Plugin URI: http://klausk.aruno.lt/jsfiddle/
Description: Embed JSFiddle into posts
Version: 1.0
Author: IdeaG
Author URI: http://klausk.aruno.lt
License: GPL2
<?php
add_filter('pre_get_posts', 'klausk_category_post_types');
function klausk_category_post_types($query) {
if((is_category() && $query->is_main_query()) {
$post_type = get_query_var('post_type');
if($post_type)
$post_type = $post_type;
else
$post_type = array('post','resort');
$query->set('post_type',$post_type);
<?php
function klausk_resort() {
$args = array(
'public' => true,
'hierarchical' => false,
'label' => __('Resort','tema')
);
register_post_type( 'resort', $args );
register_taxonomy_for_object_type('category', 'resort');
}
<?php
function klausk_page_category() {
register_taxonomy_for_object_type('category', 'page');
}
add_action( 'init', 'klausk_page_category' );
?>
@ideag
ideag / style.css
Last active August 29, 2015 14:04
.tiny_coffee_form button {
background-color:#000; /* pasirinkite norimą spalvą */
}
<?php
$slider_show = get_option('general_enable_slider');
$slider_auto = get_option('general_auto_play');
$slider_speed = get_option('general_slider_delay');
$slider_animation_time = get_option('general_animation_time');
if(empty($slider_speed)) {$slider_speed = "4000";}
if(empty($slider_animation_time)) {$slider_animation_time = "1000";}
if($slider_show[0] == 'yes') :
// if($slider_show[0] == 'yes') {
?>
@ideag
ideag / delete.php
Created July 17, 2014 13:58
Remove WordPress nav menu item if asociated page is trashed
<?php
add_action( 'publish_to_trash', 'klausk_delete_menu_item' );
function klausk_delete_menu_item($post) {
// tik puslapiams
if( $post->post_type !== 'page' )
return;
// jei tema nepalaiko meniu - nieko daryti nereikia
if ( ! current_theme_supports( 'menus' ) ) { return; }
// trinamas meniu punktas
_wp_delete_post_menu_item($post->ID);
<?php
$post_id = 500
$p = get_post($post_id);
$args = array(
'date_query' => array(
'before' => $p->post_date,
// 'after' => $p->post_date
'inclusive' => true,
),
'exclude'=>$post_id
@ideag
ideag / functions.php
Last active August 29, 2015 14:03
Proof of concept - offset get_posts/WP_Query by ID
<?php
class Klausk_Filter {
private $id = 0;
private $compare = '<';
public function __construct($id,$compare = '<') {
$this->id = intval($id);
$this->compare = $compare;
}
public function filter($where){
$where .= " AND `ID` {$this->compare} {$this->id}";