Limit rendering of images

Asked

Viewed 30 times

1

I’m using the plugin https://wordpress.org/plugins/taxonomy-images/ to relate images to categories, and I’m printing icons next to the post title so(code below) but it brings all related categories and I wanted to limit to only one someone can help me?:

<?php
        print apply_filters( 'taxonomy-images-list-the-terms', '', array(
            'attr'       => array(
            'alt'   => '',
            'class' => 'img-responsive',
            'src'   => '',
            'title' => '',
         ),
        'before'       => '<div class="">',
        'after'        => '</div>',
        'before_image' => '',
        'after_image'  => '',
        'image_size'   => 'detail',
        'post_id'      => get_the_ID()
) );


                ?>
  • change your first line after <?php for print apply_filters( 'taxonomy-images-queried-term-image', '' );

  • It limits on some and other error pages =/

  • Category pages work but when I go to Home it doesn’t work, only with old code

  • I edited the answer, try again

  • The problem persists =/

  • The error here persists because the theme used (Odin) does not support this type of query (this is the error printed here at home).

  • Could edit the question with the error you are giving?

  • Notice: term_taxonomy_id is not a Property of the Current queried Object. This usually Happens when the taxonomy-images-queried-term-image-id filter is used in an Unsupported template file. This filter has been Designed to work in taxonomy Archives which are Traditionally served by one of the following template files: Category.php, tag.php or taxonomy.php. Learn more about template Hierarchy.

  • I copied the above error

Show 4 more comments

1 answer

0

I know it’s already been solved, but just to not leave unanswered if someone else also has the same problem, the solution is simple.

In line 2 of your code, you will replace the terms:

print apply_filters( 'taxonomy-images-list-the-terms',

For:

print apply_filters( 'taxonomy-images-queried-term-image'

In this case the only difference is the arguments images-list-the-terms and images-queried-term-image.

@Edit - To make it easier change the entire code.

print apply_filters( 'taxonomy-images-queried-term-image', '', array(
'attr'       => array(
    'alt'   => '',
    'class' => 'img-responsive',
    'src'   => '',
    'title' => '',
    ),
'before'     => '<div class="">',
'after'      => '</div>',
'image_size' => 'detail',
'post_id'      => get_the_ID()
 );
  • Do you have any idea how I can make one image appear on the other side? because this "before" and "after" render like this: <div><a href=""> {ALL IMAGES HERE } </a> </div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.