Skip to content

Instantly share code, notes, and snippets.

View espiat's full-sized avatar
🎯
Focusing

DER SPANIER espiat

🎯
Focusing
View GitHub Profile
Description
Filter the widget_tag_cloud_args.
apply_filters( 'widget_tag_cloud_args',
array(
'taxonomy' => $current_taxonomy,
'echo' => false
) ) );
- Solution for showing entries in the entry viewer 2 in Caldera Forms
- ONLY available, when the permalink structure is not /?p=123
Shortcode:
[caldera_forms_entry_viewer id="YOURFORMID" role='public' ]
@espiat
espiat / Fonts only with referer - .htaccess
Last active September 5, 2018 07:48
.htaccess to restrict access the font only with given domain
RewriteEngine On
RewriteCond %{HTTP:Origin} !^$|http(s)?://(www\.)?DOMAIN\.com$ [NC]
RewriteRule \.(woff|woff2|ttf|eot)$ - [NC,L]
RewriteCond %{HTTP_REFERER} !.
RewriteRule \.(woff|woff2|ttf|eot)$ - [F,NC,L]
Options -Indexes
@espiat
espiat / functions.php
Created September 7, 2018 13:42
Content Export in WP with <p> - Tag
function content_export_with_paragraph($content) {
return wpautop($content);
}
add_filter('the_content_export', 'content_export_with_paragraph', 999);
@espiat
espiat / functions.php
Created September 12, 2018 14:43
show the yoast primary categorie or first category - helpful for single.php
function yoast_priamry() {
$category = get_the_category();
$useCatLink = false;
// If post has a category assigned.
if ($category){
$category_display = '';
$category_link = '';
if ( class_exists('WPSEO_Primary_Term') )
{
// Show the post's 'Primary' category, if this Yoast feature is available, & one is set
@espiat
espiat / functions.php
Created September 12, 2018 14:48
wenn kein excerpt dann content bis more und wenn nicht dann auf XXX Zeichen des contens begrenzt
/**
* the real and better post excerpt
*/
function the_real_excerpt(){
global $post;
if ( has_excerpt() ) :
echo get_the_excerpt();
// Is there a more tag? Then use the teaser. ()
elseif ( strpos( $post->post_content, '<!--more-->' ) ) :
@espiat
espiat / for functions.php (Child-Theme)
Created October 8, 2018 08:18
Caldera Forms (autopopulate ) & ACF (Field/ Meta)
function filter_caldera_forms_autopopulate_post_type_args( $args, $field ) {
if( 'fld_3126036' === $field[ 'ID' ] ){ // your field ID !!!!
$args[ 'meta_query' ] =
array(
array(
'key' => 'status', // ACF field name
'value' => 'sold', // ACF field value
'compare' => '!=', // in this case every post is NOT sold
)
@espiat
espiat / api-requests.php
Last active July 10, 2019 17:57
api header request
function irgendwasenheader(){
$testrequest = wp_remote_get( 'https://www.domain.com/wp-json/wp/v2/CPT/' );
if( is_wp_error( $testrequest ) ) {
// Keine Daten
return false;
}
$testbody = wp_remote_retrieve_body( $testrequest );
$irgendwasengesamt = wp_remote_retrieve_header($testrequest, 'x-wp-total' );
$apiseiten = wp_remote_retrieve_header($testrequest, 'x-wp-totalpages' );
<?php
/**
* Set a max length attribute for all paragraph fields in Caldera Forms
*/
add_filter( 'caldera_forms_field_attributes-paragraph', function( $attrs ){
$attrs[ 'maxlength' ] = 255;
return $attrs;
});
@espiat
espiat / gutenberg-block-extraction.php
Created January 24, 2019 08:52
Gutenberg (special) Block selection for excerpt in post grid (for example)
function d6bridge_filter_for_results($content){
if (is_archive('gnt-result') || is_archive('nap-result')) {
if ( gutenberg_content_has_blocks( $content ) ) {
$blocks = gutenberg_parse_blocks( $content );
$content = '';
foreach ($blocks as $block) {
if ($block->blockName == 'rsvpbridge/competition-result') {
$content .= $block->innerHTML;
}
}