Skip to content

Instantly share code, notes, and snippets.

View oliwa's full-sized avatar

Oliver Hulisz oliwa

View GitHub Profile
@oliwa
oliwa / .htaccess
Created August 14, 2017 12:19
Wordpress .htaccess
# Wordpress Stuff (Single or Multisite)
# Disallow Directoy Browsing
Options -Indexes
# Enanble File Compression
# Quelle: http://magazin.phlow.de/wordpress/beschleunigen/
<ifModule mod_gzip.c>
mod_gzip_on Yes
@oliwa
oliwa / ul-rows.css
Last active December 5, 2018 07:05
UL Rows
/* Repeating items (3 in a row)
-------------------------------------------------------------------------------------------------- */
ul.row-of-three {
margin: 0;
padding: 0;
list-style: none;
}
ul.row-of-three li {
float: left;
margin-right: 2%;
@oliwa
oliwa / domain-change.sql
Created February 20, 2018 06:33
SQL Queries to Change Website Domain
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://test.rudrastyh.com', 'https://rudrastyh.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://test.rudrastyh.com', 'https://rudrastyh.com');
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://test.rudrastyh.com','https://rudrastyh.com');
UPDATE wp_comments SET comment_content = REPLACE (comment_content, 'http://test.rudrastyh.com', 'https://rudrastyh.com');
UPDATE wp_comments SET comment_author_url = REPLACE (comment_author_url, 'http://test.rudrastyh.com','https://rudrastyh.com');
UPDATE wp_posts SET guid = REPLACE (guid, 'http://test.rudrastyh.com', 'https://rudrastyh.com') WHERE post_type = 'attachment';
// https://rudrastyh.com/tools/sql-queries-generator
@oliwa
oliwa / snippet.php
Last active November 27, 2018 09:34
Pass a value via variable in Contact Form 7
// see Source
// http://blog.ostryweb.cz/2017/05/pass-values-from-shortcode-in-contact.html
// in Contact Form 7 Admin
[text my-extra-field default:shortcode_attr readonly]
// in Wordpress Template
<?php
$my_extra_field = "This can be dynamic";
$shortcode = '[contact-form-7 id="123" title="Name of the form" my-extra-field="'.$my_extra_field'"]';
@oliwa
oliwa / shortcode.php
Last active December 5, 2018 07:04
Wordpress Shortcode with multiple Variables
<?php
function ppai_quotebox( $atts ) {
$templateDirectory = get_bloginfo('template_directory');
extract( shortcode_atts( array(
'imgpath' => $templateDirectory.'/images/quote-dummy.jpg',
'quote' => 'Ohne ein Zitat sehe ich scheisse aus',
'author' => 'Die Zitatbox',
@oliwa
oliwa / snippet.php
Last active December 5, 2018 07:02
Redirect single-ctp.php to homepage
<?php
// How to disable the single view for a custom post type
// see https://wordpress.stackexchange.com/questions/128636/how-to-disable-the-single-view-for-a-custom-post-type
add_action( 'template_redirect', 'wpse_128636_redirect_post' );
function wpse_128636_redirect_post() {
$queried_post_type = get_query_var('post_type');
if ( is_single() && 'my_post_type_name' == $queried_post_type ) {
@oliwa
oliwa / snippet.php
Created December 5, 2018 07:58
Wordpress Query for Events with Start- and End-Date
<?php // based on https://support.advancedcustomfields.com/forums/topic/how-do-i-filter-and-sort-event-posts-with-start-and-end-date/
$query_args = array(
//'paged' => 1,
'post_type' => 'termine',
'post_status' => 'publish',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'posts_per_page' => -1,
'meta_key' => 'event_start_date',
'meta_query' => array(
@oliwa
oliwa / subnavigation.php
Last active March 14, 2025 21:17
pages submenu with active current page
<?php global $id;
$args = array(
'child_of' => 39,
'sort_column' => 'menu_order',
'post_type' => 'page',
);
$pages = get_pages($args); ?>
<ul class="submenu">
<?php foreach ( $pages as $page ) { ?>