Question

I am not that pro with php but i have good concept and can find my way in cleverly, this forum have always put me ahead of the game due to people like you who share as the care,

I have a site that act as a blog site and i have multiple countries scrolling on the top.

<a href="http://ca.unitysofts.com/">http://ca.unitysofts.com/</a>

What i want to achive is when some one click on say "china" flag, the next page will show all the post from china tag. Its working but the twist is, i want to customize

each tag page for each country currently its like this

ca.unitysofts.com/tag/china/

I want to customize this ,so each result first check the tag id, then execute an image of that country flag some wikipedia info of that country ,and then below start the blog roll,

I hope i have explained it, i am sorry for my ignorance , may be the answer is very simple,

thanks

Was it helpful?

Solution

put this code in functions.ph

define('IMAGES',get_stylesheet_directory_uri().'/img');  

where img is the directory where the images for the flags are present

<?php
    get_header();
    $queried_object = get_queried_object();
    $term = $queried_object->name;


    switch ($term) {
        case "china":
            echo '<img src="  <?php echo IMAGES; ?>/china.jpg">';
            break;
        case "russia":
            echo '<img src="  <?php echo IMAGES; ?>/russia.jpg">';
            break;
        case "india":
            echo '<img src="  <?php echo IMAGES; ?>/india.jpg">';
            break;
    }

    echo '
    <div class="title-head"><h1>'.$term.'</h1></div>

    <div class="blog-fixed">'; 

    $page_layout = page_sidebar_layout();
    switch ($page_layout) {

        case "sidebar-left":
            echo '
        <div id="blog-right">';
            break;

        case "sidebar-full":
            echo '
        <div id="blog-full">';
            break;

        case "sidebar-right":
            echo '
        <div id="blog-left">';
            break;
    }

    if (have_posts())
        while (have_posts()):
            the_post();
            $image_id = get_post_thumbnail_id($post->ID);
            $cover    = wp_get_attachment_image_src($image_id, 'short-one');
            $no_cover = get_template_directory_uri();
            $author   = get_the_author_meta('ID');
            echo '
            <div class="bl2page-archive">';
                echo '
                <div class="bl2page-cover">';
                if ($image_id) {
                    echo '
                    <a href="' . get_permalink() . '"><img src="' . $cover[0] . '" alt="' . get_the_title() . '" /></a>';
                } else {
                    echo '
                    <a href="' . get_permalink() . '"><img src="' . $no_cover . '/images/no-cover/short-one.png" alt="no-cover" /></a>';
                }
                echo '
                    <div class="comment-bubble">
                        <span class="comment-count">' . get_comments_number() . '</span>
                    </div>
                </div>';
            echo '
                <h2 class="bl2page-title"><a href="' . get_permalink() . '" rel="bookmark">' . get_the_title($post->ID) . '</a></h2>
                <div class="bl2page-info">' . get_the_time('F jS, Y') . ' | by <a href="' . get_author_posts_url($author) . '">' . get_the_author() . '</a> </div>';
            echo '' . get_excerpt(230) . '';
            echo '

        </div>';
        endwhile;

    if (function_exists("pagination_wz")) {
        pagination_wz();
    }

    echo '
        </div><!-- end .blog(left&full&right) -->
    ';

    switch ($page_layout) {
        case "sidebar-left":
            echo '
    <div id="sidebar-left">';
            wz_setSection('zone-sidebar');
            if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar-page'));
            echo '
    </div><!-- end .sidebar-left -->';
            break;
        case "sidebar-full":
            echo '
    <div id="sidebar-right">';
            wz_setSection('zone-sidebar');
            if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar-page'));
            echo '
    </div><!-- end .sidebar-right -->';
            break;
        case "sidebar-right":
            echo '
    <div id="sidebar-right">';
            wz_setSection('zone-sidebar');
            if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar-page'));
            echo '
    </div><!-- end .sidebar-right -->';
            break;
    }

    echo '  
    </div><!-- end .blog-fixed -->';

    get_footer();
    ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top