How to find stuff

Please use Browser Search or Scroll down.

user rechte fuer menu zugriff setzen

in functions:

// get the the role object $role_object = get_role( 'editor' ); // add $cap capability to this role object $role_object->add_cap( 'edit_theme_options' );

custom 404 error page with ACF

first create a new page, name it 404 Fehler Seite

then add this to 404.php

<?php $args = array( 'post_type' => 'page', 'title' => '404 Fehler Seite' ); $your_query = new WP_Query( $args ); ?> <?php while ( $your_query->have_posts() ) : $your_query->the_post(); ?> <div class="page-content"> <section id="content" role="main"> <?php require('inc-acf-fields.php'); ?> </section> </div> <!-- end page-content --> <?php endwhile; ?>

acf google maps integration

get maps api key

insert into functions

function my_acf_init() { acf_update_setting('google_api_key', 'XXX'); } add_action('acf/init', 'my_acf_init'); create acf google maps field get coord here: www.latlong.net create 2 acf fields for icons first: image icon, allowed filetypes png second: svg icon, allowed filetypes svg (ev install safe svg plugin) create acf field for color create acf field for zoom level (range field)

src

https://www.youtube.com/watch?v=yTP4xXv40os https://www.advancedcustomfields.com/resources/google-map/#google-map%20api www.latlong.net https://codyhouse.co/gem/custom-google-map https://mapstyle.withgoogle.com/

360 product viewer for wordpress

360view, static html stand alone player for 360 product images: https://codecanyon.net/item/view360-3d-360-degree-product-viewer/ cloud alternative: https://sirv.com/

src

https://www.optimal-3d.com/de/blogposts/360-grad-produktbilder-ecommerce-trend/

redirect menu parent to first child

create page-redirect.php

then just select this page template for the parent page <?php /* Template Name: Redirect To First Child */ if (have_posts()) { while (have_posts()) { the_post(); $pagekids = get_pages("child_of=".$post->ID."&sort_column=menu_order"); $firstchild = $pagekids[0]; wp_redirect(get_permalink($firstchild->ID)); exit; } } ?>

allow svg uploads in media manager

// allow SVG uploads, but be careful, SVG can contain JS .... // just use export from sketch function cc_mime_types($mimes) { $mimes['svg'] = 'image/svg+xml'; return $mimes; } add_filter('upload_mimes', 'cc_mime_types');

stop trackback spam

for new postings

setttings -> discussion default article settings -> uncheck "ALLOW link notifications from other blogs"

for existing postings

only possible with SQL query, only do it if too much spam! select table, then run this query: UPDATE wp_posts SET ping_status="closed"; http://basicblogtips.com/stop-wordpress-trackback-spam.html

create second sidebar

create sidebar2.php

<!-- start sidebar2--> <div class="sidebar"> <div class="sidebar-menu shadow shadowbox"> <?php if ( dynamic_sidebar(2) ) : else : ?> <?php endif; ?> </div> </div> <!-- end sidebar2 -->

in templates

<?php include("sidebar2.php"); ?>

functions.php

register_sidebar(2, array ( 'name' => __( 'Sidebar Widget Area', 'blankslate' ), 'id' => 'primary-widget-area', 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 'after_widget' => "</li>", 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) );

woocommerce declare support

add_action( 'after_setup_theme', 'woocommerce_support' ); function woocommerce_support() { add_theme_support( 'woocommerce' ); }

install masonry

download the script masonry.min.js from masonry.desandro.com copy script to theme/js folder

then style images like this

img.size-auto, img.size-full, img.size-large, img.size-medium, .attachment img, #sidebar img, .wp-caption { max-width: 100%; /* When images are too wide for containing element, force them to fit. */ height: auto; /* Override height to match resized width for correct aspect ratio. */ } img.aligncenter, .wp-caption.aligncenter { margin: 0 auto 1.5em auto; max-width: 100%; height: auto; }

content slider

set posts to sticky create new page template and create loop with sticky posts then enqueue flexslider

vimeo/youtube

paste url (no snippets) in html mode in wp then download fitvids (js library to fit videos to screensize) the add function to queue the script (see lynda video)

hide update notification notify

put this in functions.php

function hide_update_notice_to_all_but_admin_users() { if (!current_user_can('update_core')) { remove_action( 'admin_notices', 'update_nag', 3 ); } } add_action( 'admin_head', 'hide_update_notice_to_all_but_admin_users', 1 );

reset Passwort

phpmyadmin -> wp_users -> click EDIT user__pass -> set function to MD5, value to NEWPASS

move scripts to footer

problem: some plugin puts the hidden form fields in the header solution: put the fields in the wp_footer before the other scripts so instead of //add_action ('wp_enqueue_scripts','stupid_scripts'); use add_action ('wp_footer','stupid_scripts');

woocommerce jquery replace word with image

in wp-content/themes/mytheme/library/js

$('.short-description').each(function() { var txt = $(this).text(); var img = '<img src="'+uploadDir+'/asdf.png" alt="' + txt + '" />' var html = txt.replace(/asdf/g, img); // replace every star with an image tag $(this).html(html); });

woocommerce checkout fields options select

$fields['billing']['partytime'] = array( 'label' => __('party Time', 'woocommerce'), 'placeholder' => _x('partytime', 'placeholder', 'woocommerce'), 'required' => true, 'clear' => true, 'type' => 'select', 'class' => array('css-party-time-class'), 'options' => array( '0' => __('Select Options', 'woocommerce' ), '07:00am' => __('07:00am', 'woocommerce' ), '07:15am' => __('07:15am', 'woocommerce' ), '07:30am' => __('07:30am', 'woocommerce' ), '07:45am' => __('07:45am', 'woocommerce' ), '11:00pm' => __('11:00pm', 'woocommerce' ) ) );

header image in each category (incl default image)

<?php if ( is_product_category() ){ global $wp_query; $cat = $wp_query->get_queried_object(); $thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); $image = wp_get_attachment_url( $thumbnail_id ); if ( $image ) { echo '<img src="' . $image . '" alt="" />'; } else { echo '<img src="' . get_bloginfo ( 'stylesheet_directory' ) . '/img/header.jpg" alt="" />'; } } ?>

woocommerce using shortcuts in php

<?php echo do_shortcode('[product_category category="gold-silver-courses" per_page="12" columns="2" orderby="price" order="desc"]'); ?>

woocommerce hide category count

add_filter( 'woocommerce_subcategory_count_html', 'jk_hide_category_count' ); function jk_hide_category_count() { // No count }

woocommerce setting orders automatically to complete

// Auto Complete all WooCommerce orders. add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' ); function custom_woocommerce_auto_complete_order( $order_id ) { global $woocommerce; if ( !$order_id ) return; $order = new WC_Order( $order_id ); $order->update_status( 'completed' ); }

src

http://docs.woothemes.com/document/automatically-complete-orders/

add custom body class

add_filter( 'body_class', 'my_neat_body_class'); function my_neat_body_class( $classes ) { if ( is_page(7) || is_category(5) || is_tag('neat') ) $classes[] = 'neat-stuff'; return $classes; }

custom field &quot;Einheit&quot; after price

custom field -> add new -> Einheit: Stk

dann in functions

add_filter( 'woocommerce_price_format', 'overwrite_woocommerce_price_format', 10, 2 ); function overwrite_woocommerce_price_format( $format, $currency_pos ) { global $post; if ( $post->post_type != 'product' ) return $format; $custom_field = get_post_meta( $post->ID, 'Einheit', true ); // This will return your custom field value return $format . ' ' . __( $custom_field, 'woocommerce' ); // Here you'll append your custom field with price }

for importing with woo product importer

map name, sku, price, einheit (post meta: einheit), usw disable all that are being not imported!! http://stackoverflow.com/questions/17586493/woocommerce-append-custom-field-after-price-in-content-single-product-php

custom themes with woocommerce

copy themes page.php and rename it woocommerce.php page.php woocommerce.php WOOCOMMERCE FOLDER/ replace the loop with: <?php woocommerce_content(); ?>

to get sidebars

http://support.goodlayers.com/creating-woocommerce-template/

use custom pages types and insert categories manually:

[product_category category="Bier" per_page="12" columns="4" orderby="date" order="desc"] http://wordpress.stackexchange.com/questions/88033/woocommerce-shop-page-to-use-my-custom-template

disable shop page

woocommerce -> settings -> pages -> click x to remove

custom shop loop

<ul class="products"> <?php $args = array( 'post_type' => 'product', 'posts_per_page' => 12 ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); woocommerce_get_template_part( 'content', 'product' ); endwhile; } else { echo __( 'No products found' ); } wp_reset_postdata(); ?> </ul><!--/.products-->

create custom woocommerce theme

create new folder named woocommerce and copy all templates from /woocommerce/templates/ to it. http://docs.woothemes.com/document/template-structure/

find current template, displaying name

put this in functions: add_filter( 'the_content', 'so_9405896_the_content_filter', 20, 1 ); function so_9405896_the_content_filter( $content ) { if( is_admin() || !current_user_can( 'administrator' ) ) return $content; global $template; $the_templ = '<strong style="background-color: #CCC;padding:10px">TEMPLATE = ' . basename( $template ) . '</strong><br />'; $content = sprintf( $the_templ . '%s', $content ); return $content; }

customize wp pages

create copy of PAGE.php with new template name PAGE-full.php <?php /* Template Name: full width */ ?> in wordpress: pages -> page attributes -> change template