Forums

using the [gallery] tag (7 posts)

  1. Tarmu
    Member
    Posted 3 years ago #

    As I always post galleries into a special gallery category, I was thinking of some automation generating the gallery tag.

    I want to automatically echo the tag:
    [gallery columns="6" orderby="post_name"]
    If the post is in the gallery category.

    I managed to get it working in single.php and the in_category check. But the php echo shows the real plain text [gallery columns="6" orderby="post_name"] and wordpress doesn't interpreter it.

    How can I get this working?

  2. kkarpieszuk
    Member
    Posted 3 years ago #

    what do you mean when you write "I managed"? what exactly you did?

    did you read http://codex.wordpress.org/Using_the_gallery_shortcode ?

  3. Tarmu
    Member
    Posted 3 years ago #

    I opened single.php and made a php if statement.

    Something like this (not real code, because I removed it again).

    <?php if ( is_category(4)) echo {("[gallery columns="6" orderby="post_name"]'); } ?>

    category 4 is "Gallery".

    So it means that if a post is in the category gallery it should automatically show all thumbnails instead that I have to manually insert the gallery in the post.

    The IF works, but the only problem is that the output are not the gallery thumbnails, but the plain text tags -> [gallery columns="6" orderby="post_name"]

  4. Tarmu
    Member
    Posted 3 years ago #

    You get me now? :D I don't want to insert the [gallery] tag into all my posts manually. WordPress should insert the tag automatically in all my posts which belong to the category "gallery"

  5. kkarpieszuk
    Member
    Posted 3 years ago #

    :)

    you just echo-ing string "[gallery...", php and wp do it as you want

    if you want to use gallery code, you need to use this what is at site which i mentioned

    echo do_shortcode('[gallery...

  6. Tarmu
    Member
    Posted 3 years ago #

    Thanks! that works great :D

  7. Tarmu
    Member
    Posted 3 years ago #

    Now I only need to load a random thumbnail from the gallery. Do you know how to get that working?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags