Skip to content

Instantly share code, notes, and snippets.

View chrdesigner's full-sized avatar

César Ribeiro chrdesigner

View GitHub Profile
@chrdesigner
chrdesigner / function-polylang.php
Created October 8, 2024 14:46
Função onde eu aplico um select de idioma para exibir somente o meus posts referente ao idioma selecionado, o mesmo é aplicado somente em "post, page ou portfolio"
<?php
/**
* Filtra os posts por idioma no painel administrativo.
*
* Apenas exibe posts em um determinado idioma, caso o plugin Polylang esteja
* ativo e o tipo de post seja post, page ou portfolio.
*
* O idioma atual pode ser passado como par metro GET 'idioma'.
*
<?php
//add function inside functions.php
//add wordpress dashicons frontend
add_action( 'wp_enqueue_scripts', 'load_dashicons_front_end' );
function load_dashicons_front_end() {
wp_enqueue_style( 'dashicons' );
}
//after create in your file single.php ou page.php add code echo <?php chr_edit_post(); ?:>
@chrdesigner
chrdesigner / 00-README.md
Last active June 20, 2024 21:07
Configure manual SMTP

=== GMAIL ===

Password: You can generate an App password. Using this Google App Password Link or go to Google Account Settings>Security>App Password.

<?php if( have_rows('repeater_field') ): ?>
<ul>
<?php while ( have_rows('repeater_field') ) : the_row(); ?>
<li><?php the_sub_field('sub_field'); ?></li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
@chrdesigner
chrdesigner / .htaccess
Created December 21, 2023 15:13
htaccess redirect www to non-www
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
</IfModule>
@chrdesigner
chrdesigner / functions.php
Created November 17, 2022 14:21
Use GD instead of Imagick.
<?php
/** * Use GD instead of Imagick.
*/
function chr_use_gd_editor($array) {
return array( 'WP_Image_Editor_GD' );
}
add_filter( 'wp_image_editors', 'chr_use_gd_editor' );
@chrdesigner
chrdesigner / filter-external.js
Created September 17, 2018 19:21
Sub Menu + Filter TAG ~ External
$('.filterBlog a').on('click', function(e) {
filterBlogHash(this.hash, e);
});
$(window).on('load',function() {
filterBlogHash(window.location.hash);
});
function filterBlogHash(hash, e) {
if(hash === '') {
@chrdesigner
chrdesigner / filter.js
Created September 17, 2018 19:20
Sub Menu + Filter TAG ~ Simple
$('.filterBlog').on('click', 'a', function(e){
e.preventDefault();
var hash = $(this).attr('href').replace(/^.*?(#|$)/,'');
$('.filter a.type').each(function (index, value) {
// console.log('filter' + index + ':' + $(this).attr('id'));
@chrdesigner
chrdesigner / functions.php
Last active November 9, 2017 12:08
Function to create a custom related post list by tag and category
<?php
/**
* Related Posts.
*
* Usage:
* To show related by categories:
* Add in single.php <?php chr_related_posts(); ?>
* To show related by tags:
* Add in single.php <?php chr_related_posts( 'tag' ); ?>
*
@chrdesigner
chrdesigner / 00-README.md
Last active June 14, 2017 16:46
Git List - Post views Count