- Edit the
functions.php
file in your hueman-child
theme.
- Add the following code to create a shortcode for listing private documents by category:
<?php
// Enqueue parent theme styles
function hueman_child_enqueue_styles() {
wp_enqueue_style('hueman-parent-style', get_template_directory_uri() . '/style.css');
}
add_action('wp_enqueue_scripts', 'hueman_child_enqueue_styles');
// Shortcode to list private documents by category
function list_private_documents_by_category() {
// Query private documents
$args = array(
'post_type' => 'post', // Change to 'documents' if using a custom post type
'posts_per_page' => -1,
'post_status' => 'private',
'orderby' => 'category',
'order' => 'ASC'
);
$query = new WP_Query($args);
if ($query->have_posts()) {
$output = '<ul>';
while ($query->have_posts()) {
$query->the_post();
$categories = get_the_category();
if (!empty($categories)) {
foreach ($categories as $category) {
$output .= '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a> (' . esc_html($category->name) . ')</li>';
}
}
}
$output .= '</ul>';
wp_reset_postdata();
} else {
$output = 'No private documents found.';
}
return $output;
}
add_shortcode('private_documents', 'list_private_documents_by_category');