This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Get unattached files in Media Library */ | |
$args_search = array( | |
'post_type' => 'attachment', | |
'post_status' => 'inherit', | |
'post_parent' => 0, | |
'post_mime_type' => 'application/pdf', // Only PDFs. | |
'posts_per_page' => 40, | |
'orderby' => 'id', | |
'order' => 'ASC', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
WordPress settings list (serialized data hidden): | |
/wp-admin/options.php | |
Jetpack settings by modules (defualt hidden): | |
/wp-admin/admin.php?page=jetpack_modules | |
List Reusable Blocks (CPT): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Shortcode accesses external database and returns data in HTML table. | |
* | |
* Shortcode is: [my-db-data]. | |
* Uses WP class: | |
* @link https://developer.wordpress.org/reference/classes/wpdb/ | |
* Sets transient with db data and 24 hour expiration. | |
* | |
* @return string $data_html HTML table with database data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/******************************* | |
=Comments: Remove | |
******************************/ | |
/* Remove comments support from native post types | |
* | |
* Removes Comments column from admin post lists and Comments meta-box from Edit Post. | |
*/ | |
function headecon_remove_comments() { | |
remove_post_type_support( 'post', 'comments' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Insert class into body tag for highest level Category or Page. | |
* | |
* Pages and Categories with identical slugs get the same class. | |
* Works on Pages, Posts, and Category achives. | |
* | |
* @return string $top_slug Class name for body tag. | |
*/ | |
function top_cat_or_page_body_class( $class ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Use filemod timestamp for version number. | |
* | |
* For setting cache-busting version number in script registrations. Usage: | |
* wp_register_script( 'handle', $file_url, array(), headecon_filemod_vers( $file_path ) ); | |
* | |
* @param string $path Path of script/style file | |
* @return string $vers File-modification timestamp or WordPress version | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add files to Media Library; attach files to posts. | |
* | |
* This is for adding files to Media Library already in /uploads/. | |
* If files are elsewhere, adapt script. | |
* | |
* Attempts to attach file to post: | |
* Searches thru post content for the filename. | |
* If a post is found, then uses post ID and publish-date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* List GUIDs of all files of specified mime-type in Media Library. */ | |
$query_images_args = array( | |
'post_type' => 'attachment', | |
'post_status' => 'inherit', | |
'post_mime_type' => 'application/pdf', // Only PDFs. | |
'posts_per_page' => -1, | |
); | |
$query_images = new WP_Query( $query_images_args ); | |
print_r( wp_list_pluck( $query_images->posts, 'guid' ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Use Yoast SEO's Primary Category feature only on Categories. */ | |
function myprefix_yoast_primary_tax( $all_taxonomies ) { | |
$args = array( 'name' => 'category' ); | |
$all_taxonomies = get_taxonomies( $args, 'objects' ); | |
return $all_taxonomies; | |
} | |
add_filter('wpseo_primary_term_taxonomies', 'myprefix_yoast_primary_tax' ); | |
?> |