Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

S

schneiderbrett

@schneiderbrett
About
Posts
10
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Shortcode to show list of project-related categories/tags on Project Page itself
    S schneiderbrett

    And last question resolved again. Here the code:

    function createPostListSubCatWork() {
    	global $post;
    	$categories = wp_get_object_terms( $post->ID, 'category', [ 'parent' => 1, 'number' => 99 ] );
        $categoryOutput = [];
    
        if (!empty($categories)) {
            array_push($categoryOutput, '<ul class="_Default">');
            foreach($categories as $category) {
                array_push($categoryOutput, '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </br> ');
            }
            array_push($categoryOutput, '</ul>');
        }
    
        return implode('', $categoryOutput);
    }
    add_shortcode('work_cats_pg', 'createPostListSubCatWork');
    
    • List categories for the current post: [work_cats_pg]
    • The categories should be children of category 1.
    • No more than 99 positions should be displayed.

    Source which kinde resolved it for me: https://wordpress.stackexchange.com/questions/330128/display-a-list-of-subcategories-from-specific-category-a-post-belongs-to

    Best regards,
    Amadezs

    General Discussion

  • Any way to implement tags?
    S schneiderbrett

    Awesome! Thank you very much :)

    General Discussion tags
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Recent
  • Tags
  • Popular
  • Users
  • Search