<?php defined('ABSPATH') or exit; /** * Remove articles with custom-field "hidden_from_archive" and value "1" form overview pages. */ add_action('pre_get_posts', function (WP_Query $query) { // make sure we have something to act on.. static pages don't have the globals if (empty($query->query)) { return; } // detect overview pages if (!$query->is_tax(array('wpkb-category', 'wpkb-keyword')) && !$query->is_post_type_archive('wpkb-article') && !$query->is_page(wpkb('options')->get('custom_archive_page_id'))) { return; } $query->set('meta_query', array('relation' => 'OR', array('key' => 'hidden_from_archive', 'value' => false, 'type' => 'BOOLEAN'), array('key' => 'hidden_from_archive', 'compare' => 'NOT EXISTS'))); });
exit; } // define version define('WPKB_FILE', __FILE__); define('WPKB_VERSION', '1.2'); // load composer autoloader if (!function_exists('wpkb')) { require __DIR__ . '/vendor/autoload.php'; } // load constants, filters, actions & shortcodes require __DIR__ . '/src/default-actions.php'; require __DIR__ . '/src/default-filters.php'; require __DIR__ . '/src/shortcodes.php'; // instantiate object tree global $wpkb; $wpkb = wpkb(); $wpkb['options'] = $options = new Options('wpkb', array('custom_archive_page_id' => 0)); $router = new Router($options->get('custom_archive_page_id', 0)); $router->add_hooks(); $wpkb['plugin'] = $plugin = new Plugin(WPKB_VERSION, __FILE__, __DIR__); $wpkb['categories'] = new Term_List('wpkb-category'); $wpkb['keywords'] = new Term_List('wpkb-keyword'); // search $wpkb['search'] = $search = new Search($plugin); $search->add_hooks(); // breadcrumbs $wpkb['breadcrumbs'] = function () use($router) { return new Breadcrumbs\Crumbs($router->archive_page); }; // code highlighting $highlighting = new CodeHighlighting($plugin);
/** * @return string */ function wpkb_breadcrumbs() { return wpkb('breadcrumbs'); }