Skip to content

Instantly share code, notes, and snippets.

@pgroot91
pgroot91 / gist:1e241aa3de3053218cd2b3245ede7036
Created May 14, 2020 20:39 — forked from urre/gist:846b89237da760839b3d
Get network wide recent posts from a WordPress Multisite (1 post from every blog except main site), order by date and only show author once (unique authors). Used on http://vertikals.se/
<?php
// Get all blog ids in network except main site (id 1)
$blogs = $wpdb->get_results("
SELECT blog_id
FROM {$wpdb->blogs}
WHERE site_id = '{$wpdb->siteid}'
AND spam = '0'
AND deleted = '0'
AND archived = '0'
@pgroot91
pgroot91 / api.php
Created December 30, 2020 11:17 — forked from pixelbrackets/api.php
Simple PHP script to test and use cURL
<?php
/**
* Simple request response script
*
* Point you cURL request to this script to see all incoming data
*/
echo '*API*'. PHP_EOL;
@pgroot91
pgroot91 / image-upload-field-custom-taxonomy
Created January 2, 2021 11:15 — forked from mathetos/image-upload-field-custom-taxonomy
Add Image Upload Field to Custom Taxonomy
<?php
/* Add Image Upload to Series Taxonomy */
// Add Upload fields to "Add New Taxonomy" form
function add_series_image_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="series_image"><?php _e( 'Series Image:', 'journey' ); ?></label>
@pgroot91
pgroot91 / image-upload-field-custom-taxonomy
Created January 2, 2021 11:17 — forked from gagimilicevic/image-upload-field-custom-taxonomy
Add Image Upload Field to Custom Taxonomy
<?php
/* Add Image Upload to Series Taxonomy */
// Add Upload fields to "Add New Taxonomy" form
function add_series_image_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="series_image"><?php _e( 'Series Image:', 'journey' ); ?></label>
@pgroot91
pgroot91 / ajax-action.php
Created April 17, 2021 14:02 — forked from danielpataki/ajax-action.php
Twenty Fifteen AJAX
add_action( 'wp_ajax_nopriv_ajax_pagination', 'my_ajax_pagination' );
add_action( 'wp_ajax_ajax_pagination', 'my_ajax_pagination' );
function my_ajax_pagination() {
echo get_bloginfo( 'title' );
die();
}
@pgroot91
pgroot91 / function.php
Created August 13, 2021 10:26 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}