Skip to content

Instantly share code, notes, and snippets.

View oliwa's full-sized avatar

Oliver Hulisz oliwa

View GitHub Profile
@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 ) { ?>
@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 / 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 / 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 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 / 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 / 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 / .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 / repeater.php
Created February 21, 2017 15:07
Repeater Field with Gallery
<?php if( have_rows('mede_events') ): while ( have_rows('mede_events') ) : the_row(); ?>
<hr/>
<h2><i class="fa fa-flag"></i> <?php the_sub_field('med_event_title'); ?></h2>
<?php the_sub_field('med_event_copy'); ?>
<?php $images = get_sub_field('med_event_gallery'); ?>
<?php if( $images ): foreach( $images as $image ): ?>
<a href="<?php echo $image['url']; ?>">
@oliwa
oliwa / show-hide-repeater-field.php
Created February 4, 2017 10:50
Show Hide for a repeater field
<?php if( have_rows('show_hide_repeater') ): ?>
<h2><?php the_field('show_hide_repeater_headline'); ?></h2>
<?php while ( have_rows('show_hide_repeater') ) : the_row(); ?>
<div class="open-close">
<a class="infobox-button close" href="#">
<h3 title="Projekt öffnen/schließen"><?php the_sub_field('show_hide_title'); ?></h3>
<span class="more"><i title="Projekt öffnen" class="fa fa-chevron-down"></i></span>
<span class="hide"><i title="Projekt schließen" class="fa fa-chevron-up"></i></span>
</a>