0

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

8
  • [link]pastebin.com/9DrDmrHb[link] this is the php file that genrates the tag file list, Jul 10, 2015 at 20:52
  • no code is there in pastebin
    – terminator
    Jul 10, 2015 at 21:18
  • i am sorry , here it is, pastebin.com/cBMYr9c9 Jul 10, 2015 at 21:26
  • does these tags have featured image set? Means different tags have different images , like china tag have flag of china?
    – terminator
    Jul 10, 2015 at 21:48
  • U need to use tag.php , I think the code you pasted was for category.php And these countries you are talking about , these are tags and not countries right?
    – terminator
    Jul 10, 2015 at 21:53

1 Answer 1

0

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();
    ?>
11
  • @Rohan Zakie so it did work!!!! ???
    – terminator
    Jul 11, 2015 at 11:53
  • i am just going to try in few moments, i have seen what you have done, and its clever. bundel of thanks u rock. Jul 11, 2015 at 16:18
  • i get this error Fatal error: Call to undefined function get_the_tag() in /home/unity007/public_html/ca/wp-content/themes/today/archive.php on line 3 Jul 11, 2015 at 23:05
  • fixed , yup its working, let me play around with it, thanks @amritanshu ur great Jul 11, 2015 at 23:12
  • i think get_the_tag may not work. Edited the code. And place that in tag.php and not in archive.php
    – terminator
    Jul 11, 2015 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.