WordPress.org

Ready to get started?Download WordPress

Forums

Help me inserting the $posttag in a php include function! (2 posts)

  1. diego018
    Member
    Posted 5 years ago #

    i want that my blog does the following.
    When the user is at
    myblog.com/tag/coldplay

    display the next article:
    myblog.com/wp-content/themes/mytheme/articles/colplay.php at the top of the posts.

    now i have done this succesfully. i inserted this code in the archive.php

    <?php
    echo '	';
    if ( is_tag(coldplay) ) {
     ' &raquo;  '; include(TEMPLATEPATH . '/articles/coldplay.php');
    }
    echo '
    ';
    ?>

    but i want with the help of php, and $posttag save me some work since i have a lot of tags with lots of articles. (the article name is the same as the tag) but i dont know how to insert the tag in the "include" path.

    can you help me? it´s the only thing that i need to run my theme smoothly. with what code should i replace the /articles/coldplay.php??

    i was thinking in using

    <?php
    echo '	';
    if ( is_tag($posttag) ) {
     ' &raquo;  '; include(TEMPLATEPATH . '/articles/$posttag.php');
    }
    echo '
    ';
    ?>

    but it didn´t work. hope you can understand me. how can i get the tag name and assign it the value of $posttag?
    thanks for your help!

  2. diego018
    Member
    Posted 5 years ago #

    update:
    i have found this:

    <?php $current_tag = single_tag_title("", false); ?>

    this gets the title of the tag. how can i add it to

    include(TEMPLATEPATH . '/articles/coldplay.php');

    and

    if ( is_tag(coldplay) ) {

    replacing coldplay??

Topic Closed

This topic has been closed to new replies.

About this Topic