Skip to content

Instantly share code, notes, and snippets.

View wpchannel's full-sized avatar
:octocat:

Aurélien Denis wpchannel

:octocat:
View GitHub Profile
@thierrypigot
thierrypigot / bcpj_query_exclude_offre_id.php
Created May 19, 2015 17:42
ACF : Exclude current post/page/cpt from relationship field results
<?php
/**
* Exclude current post/page/cpt from relationship field results
*/
add_filter('acf/fields/relationship/query/name=NAME-OF-THE-FIELD', 'bcpj_query_exclude_offre_id', 10, 3);
function bcpj_query_exclude_offre_id( $options, $field, $the_post )
{
if( is_admin() )
{
$options['post__not_in'] = array( $the_post->ID );
@jason-murray
jason-murray / functions.php
Last active May 28, 2023 16:01
Adds all "visible" custom fields to the custom search excerpt for Relevanssi, code is based on the indexing code used in Relevanssi to add these fields to the index.
// Relevanssi add content to custom excerpts.
add_filter('relevanssi_excerpt_content', 'custom_fields_to_excerpts', 10, 3);
function custom_fields_to_excerpts($content, $post, $query) {
$custom_fields = get_post_custom_keys($post->ID);
$remove_underscore_fields = true;
if (is_array($custom_fields)) {
$custom_fields = array_unique($custom_fields); // no reason to index duplicates
foreach ($custom_fields as $field) {
@Zodiac1978
Zodiac1978 / .htaccess
Last active January 27, 2024 14:06
Safer WordPress with these .htaccess additions
# Don't show errors which contain full path diclosure (FPD)
# Use that line only if PHP is installed as a module and not per CGI
# try using a php.ini in that case.
# Change mod_php5.c to mod_php7.c if you are running PHP7
<IfModule mod_php5.c>
php_flag display_errors Off
</IfModule>
# Don't list directories
<IfModule mod_autoindex.c>