Wordpress - archives for CPT

Developer
Size
1,613 Kb
Views
18,216

How do I make an wordpress - archives for cpt?

What is a wordpress - archives for cpt? How do you make a wordpress - archives for cpt? This script and codes were developed by Cory Schadt on 19 October 2022, Wednesday.

Wordpress - archives for CPT Previews

Wordpress - archives for CPT - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Wordpress - archives for CPT</title>
</head>
<body> to functions
add_filter( 'getarchives_where', 'getarchives_where_filter', 10, 2 );
add_filter( 'generate_rewrite_rules', 'generate_newsr_rewrite_rules' );
function getarchives_where_filter( $where, $args ) { if ( isset($args['post_type']) ) { $where = "WHERE post_type = '$args[post_type]' AND post_status = 'publish'"; } return $where;
}
function generate_newsr_rewrite_rules( $wp_rewrite ) { $newsr_rules = array( 'news-releases/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$' => 'index.php?post_type=news-releases&year=$matches[1]&monthnum=$matches[2]&day=$matches[3]', 'news-releases/([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?post_type=news-releases&year=$matches[1]&monthnum=$matches[2]', 'news-releases/([0-9]{4})/?$' => 'index.php?post_type=news-releases&year=$matches[1]' ); $wp_rewrite->rules = $newsr_rules + $wp_rewrite->rules;
}
function get_archives_newsr_link( $link ) { return str_replace( get_site_url(), get_site_url() . '/news-releases', $link );
};
to template
<?php
add_filter( 'get_archives_link', 'get_archives_newsr_link', 10, 2 );
wp_get_archives( array( 'post_type' => 'news-releases', 'type' => 'yearly' ) );
wp_get_archives( array( 'post_type' => 'news-releases', 'type' => 'monthly' ) );
wp_get_archives( array( 'post_type' => 'news-releases', 'type' => 'daily' ) );
remove_filter( 'get_archives_link', 'get_archives_newsr_link', 10, 2 ); ?>
</body>
</html>
Wordpress - archives for CPT - Script Codes
Wordpress - archives for CPT - Script Codes
Home Page Home
Developer Cory Schadt
Username coryschadt
Uploaded October 19, 2022
Rating 3
Size 1,613 Kb
Views 18,216
Do you need developer help for Wordpress - archives for CPT?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Cory Schadt (coryschadt) Script Codes
Create amazing SEO content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!