jerome-toole / skindeep

1 stars 0 forks source link

Display tags for improved navigation #23

Open briggySmalls opened 7 years ago

briggySmalls commented 7 years ago

On the homepage and single posts, the tags associated with that post should be displayed. By clicking on a tag an archive should be shown that allows a user to browse other posts with the associated tag.

jerome-toole commented 7 years ago

something like this?

foreach($categories as $category){
   echo $category->name;
   $cat_link = get_category_link($category->cat_ID);
   echo '<a href="'.$cat_link.'">'.$category->name.'</a>';
}
jerome-toole commented 7 years ago

For styling, I quite like this from Vice:

image

Alternatively, it could be white text in a black box.

image

briggySmalls commented 7 years ago

So catch-base already attempts to display categories/tags but they've been hidden using CSS added in the customizer. I've used the existing mechanism to move the categories/tags to the 'post-credits' section of a single post, but the same html seems to end up messed when it's used on the gallery view. All posts appear in the 'Online Articles' category which is kinda useless. I suppose that will have to be suppressed if categories are listed. Do you think tags should be introduced (not currently used). Should categories be shown (e.g. Back To Basics).

jerome-toole commented 7 years ago

Ok, so the answer here is that we should create a whole new custom post type called 'Articles'. That will mean we can remove the 'online articles' category and it will also mean we can customize articles much better.

  1. Create custom post type (similar to creating new taxonomy)
  2. Ensure new CPT is queried in all the places the category used to be.
  3. Switch all 'online articles' posts over to the new CPT (using Post Type Switcher plugin)

If this feels like a lot to take on, let's talk about it on the phone or something.

Tags might be good. You could tag things with a particular topic which might go across multiple categories - 'patriarchy' or 'afro-futurism'. Something to look at in the future maybe.

On Tue, Mar 7, 2017 at 1:17 AM, briggySmalls notifications@github.com wrote:

So catch-base already attempts to display categories/tags but they've been hidden using CSS added in the customizer. I've used the existing mechanism to move the categories/tags to the 'post-credits' section of a single post, but the same html seems to end up messed when it's used on the gallery view. All posts appear in the 'Online Articles' category which is kinda useless. I suppose that will have to be suppressed if categories are listed. Do you think tags should be introduced (not currently used). Should categories be shown (e.g. Back To Basics).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jerome-toole/skindeep/issues/23#issuecomment-284589461, or mute the thread https://github.com/notifications/unsubscribe-auth/AFRZO4cUwTX3fNdiSqV-IK0lsKSr9N-4ks5rjLANgaJpZM4MT5YX .

-- 07963714722 @ http://twitter.com/jamronejamrone design.jerometoole.co.uk

briggySmalls commented 7 years ago

I think I'm happy with 1) and 3).

I am less clear on 2). Where are the 'online articles' category queries? Don't we just use the permalink structure /%category%/%postname%/?

I have a custom post type that I have swapped all my posts to. I can see them at the URL: <root>/articles or root/articles/%postname%

What permalinks do we want to access them? Should the new 'articles' post type have a slug of 'online-articles' so that previously shared links and SEO of the past are preserved?

briggySmalls commented 7 years ago

I have currently added the 'category' and 'post_tag' taxonomies to the 'sd_articles' CPT. This would see the 'online-articles' category deleted. The 'Back to basics' and 'Skin deep meets' categories would no longer have parents. Is this what we want? Or should articles have a custom 'sd_category' taxonomy that cannot also be applied to other posts?

briggySmalls commented 7 years ago

Currently I am using the following function in functions.php to reroute queries:

/**
 * @brief      Include Articles in post queries
 *
 * @param      $query  The query
 *
 * @return     None
 */
function inc_articles_in_queries($query) {
    $post_type = get_query_var('post_type');
    if ( !is_admin() &&  $query->is_main_query()) {
        if (is_home()) {
            $query->set('post_type', array( 'post', 'sd_articles'));
        } else if (is_archive() || is_category()) {
            // Anything querying for Posts should also query Articles
            if (!$post_type) {
                $post_type = array('post', 'sd_articles');
            }
            $query->set('post_type', $post_type);
        }
    } else if ($query->get('post__in')) {
        write_log($query);
        // Ensure queries for specific post IDs (e.g. featured slider) include
        // Articles
        $post_type = array('nav_menu_item', 'post', 'sd_articles');
        $query->set('post_type', $post_type);
    }
}
add_action('pre_get_posts','inc_articles_in_queries');

This seems to work OK. I think I have got this working now