Support » Plugin: Custom Post Types and Custom Fields creator - WCK » Categories Post on Front Page

  • Resolved irinae2016

    (@irinae2016)


    Hello,

    I am trying to figure out how to post/pull categories with an images on the front page by using WCK. I have downloaded a Category Images Plugin. So far I have understood how to create custom post and attach categories to it. I am not a heavy coder, please help.

    Irina

    • This topic was modified 1 year, 1 month ago by  irinae2016.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Cristian Antohe

    (@sareiodata)

    Hello Irina,

    Sorry to take this long.

    What you’re after can only be done using custom code.

    For example, if you’re using the https://wordpress.org/plugins/categories-images/ plugin you can do something like this:

    
    /*
     * List taxonomies together with their custom upload feature.
     */
    
    add_shortcode('list_taxonomy_terms', 'wck_list_taxonomy');
    function wck_list_taxonomy($atts){
        $a = shortcode_atts( array(
            'tax' => '',
        ), $atts );
    
        if( empty($a['tax']) || !function_exists('z_taxonomy_image_url') )
            return;
    
        $terms = get_terms( $a['tax'], array('hide_empty' => false) );
        $output = '<style>
    .list_tax_terms{
        list-style-type: none;
        display: flex;
        flex-wrap: wrap;
        align-content: flex-start;
    }
    
    .list_tax_terms li{
        border: 1px solid #ccc;
        border-radius: 3px;
        margin-right: 3%;
        margin-bottom: 1rem;
        padding: 0.5rem;
        flex-grow:1;
        flex-basis: 30%;
        max-width:30%;
    
        text-align: center;
    }
    
    .list_tax_terms li img{
        max-width: 100px;
        display: block;
        margin: auto;
    }
    </style>';
        if( $terms ){
            $output .= '<ul class="list_tax_terms">';
            foreach ($terms as $term) {
                $output .= '<li><img src="'.z_taxonomy_image_url( $term->term_id, 'thumbnail', TRUE ).'" /> <a href="'.get_term_link($term).'">'.$term->name.'</a></li>';
            }
            $output .= '</ul>';
        }
        return $output;
    
    }
    

    Please note this code will not work with any other image category plugin.

    You will have to create a new plugin like so: https://gist.github.com/sareiodata/76f701e01db6685829db

    Then upload that file to your server in the plugin folder, activate the plugin then use the [list_taxonomy_terms tax=”my_custom_taxonomy”] shortcode in a page of your choosing.

    Let me know if you need further help with this.

    irinae2016

    (@irinae2016)

    Thank you Cristian, we will try.

    chenpro

    (@chenpro)

    Hi there,

    I have a similar issue,
    I want to display two images based categories, one for subject (animals, object, etc.)
    and other for level (easy\hard)

    I’m using the plugin “Category and Taxonomy Image

    The problem is that I can’t display two categories with it for the same post (only one or a list),
    so I want to try to link the “subject” pictures to a category, and create a new taxonomy for “levels” using your plugin.

    bottom line – How do I display one image based your plugin?

    Thanks a lot!

    Plugin Author Cristian Antohe

    (@sareiodata)

    Hello,

    That’s more of an issue with the https://wordpress.org/plugins/wp-custom-taxonomy-image/ plugin then with our own. Basically, we’re allowing you to create new taxonomies. What you need is then extended by the Category and Taxonomy Image plugin.

    And also, your theme is responsible for listing and probably the Category and Taxonomy Image plugin that injects the images in your theme. What I can suggest is to look into the plugin and try and figure out how it’s listing the category images and why just one of them. Or ask them about it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Categories Post on Front Page’ is closed to new replies.