Skip to content

Instantly share code, notes, and snippets.

@joseyaz
joseyaz / add-rel-nofollow-checkbox.php
Created February 5, 2019 10:21 — forked from danielbachhuber/add-rel-nofollow-checkbox.php
Add a 'Add rel="nofollow" to link' checkbox to the WordPress link editor
<?php
/**
* Add a 'Add rel="nofollow" to link' checkbox to the WordPress link editor
*
* @see https://danielbachhuber.com/tip/rel-nofollow-link-modal/
*/
add_action( 'after_wp_tiny_mce', function(){
?>
<script>
<?php
$show_after_p = 2;
$content = apply_filters('the_content', $post->post_content);
if(substr_count($content, '<p>') > $show_after_p)
{
$contents = explode("</p>", $content);
$p_count = 1;
foreach($contents as $content)
{
echo $content;
function my_relationship_query( $args, $field, $post_id ) {
// only show children of the current post being edited
$args['post_date'] = 'DESC';
// return
return $args;
}
@joseyaz
joseyaz / gist:07d22b462185b958df80ecb56c6b8cc1
Created February 7, 2018 09:16
functions Facets ACF Relationship Fields
/*
=============================================================*/
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'via_sector' == $params['facet_name'] ) {
$values = (array) $params['facet_value']; // an array of post IDs (it's already unserialized)
foreach ( $values as $val ) {
$params['facet_value'] = $val;
$params['facet_display_value'] = get_the_title( $val );
$class->insert( $params ); // insert each value to the database
}
@joseyaz
joseyaz / template
Created February 7, 2018 09:14
template vias_nuevas_dado
<?php
return array(
"post_type" => "via",
"post_status" => "publish",
"orderby" => "ID",
"order" => "DESC",
"posts_per_page" => 10,
"meta_query" => array(
array(
"key" => "sector_via",