0

thanks for your guidance, here is one last but not least thing for me to learn,

i am using Today news wordpress theme, since with your help i have moved my process from category to tag based archiving, my theme give me shortcodes to display post list from specific category, like this

[blog1 items=1 cat=op-ed]

here "op-ed" is my category, and it show like this

(add http:// in below links)

s15.postimg.org/g1s8k8cmz/image.jpg

s15.postimg.org/oy30o6397/image.jpg

if you need i can attache the theme files. PS , the goal is to replace category based sorting to tag based like you helped me earlier.

the code that generated this short info is http://pastebin.com/qpLyeSsF

    <?php
$queried_object = get_queried_object();
$term = $queried_object->name;
add_shortcode("blog1", "blog_one");



function blog_one($atts, $content) {

    extract(shortcode_atts(array(

        "items" => 4,

        "cat" => null,

        "id" => null,

        "nav" => false,

        "order" => "desc",

        "orderby" => "DATE",

        "events" => null

    ), $atts));

    $order       = strtoupper($order);

    $items_count = 0;

    $items_src   = null;

    if ($id == null) {

        $query          = array(

            'orderby' => $orderby,

            'order' => $order,

            'posts_per_page' => $items,

            'category_name' => $cat

        );

        $wp_query_event = new WP_Query($query);

    }

    $items_src .= '

<div id="short-one" class="fixed">';

    while ($wp_query_event->have_posts()):

        $wp_query_event->the_post();

        global $post;

        $image_id = get_post_thumbnail_id();

        $cover    = wp_get_attachment_image_src($image_id, 'short-one');

        $no_cover = get_template_directory_uri();

        $category = get_the_category();

        $vimeo    = get_post_meta($post->ID, "post_vimeo", true);

        $youtube  = get_post_meta($post->ID, "post_youtube", true);

                $author   = get_the_author_meta('ID');

        $items_src .= '

        <div class="short-one-art">

                <div class="short-one-cover">';

        if ($vimeo or $youtube) {

            $items_src .= '<a href="' . get_permalink() . '"><div class="short-one-video"></div></a>';

        }

        $items_src .= '

                        <a href="' . get_permalink() . '">';

        if ($image_id) {

            $items_src .= '<img src="' . $cover[0] . '" alt="' . get_the_title() . '" />';

        } else {

            $items_src .= '<img src="' . $no_cover . '/images/no-cover/short-one.png" alt="no-cover" />';

        }

        $items_src .= '</a>

                        <div class="comment-bubble">

                                <span class="comment-count">' . get_comments_number() . '</span>

                        </div>';

        if ($cat != null) {

        } else {

            $items_src .= '            

                        <div class="slider-left-cat">' . $category[0]->cat_name . '</div>';

        }

        $items_src .= '</div>

                <h2><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>

                <div class="short-one-info">' . get_the_date('F jS, Y') . ' | by <a href="' . get_author_posts_url($author) . '">' . get_the_author() . '</a> | <a href="'.get_category_link($category[0]->cat_ID).'">'. $category[0]->cat_name .'</a></div>

                ' . get_excerpt(230) . '

        </div><!-- end .short-one-art -->';

    endwhile;

    wp_reset_query();

    $items_src .= '

</div><!-- end #short-one -->

';

    return $items_src;

}

let me know if you need any more lead to this culprit

thanks

  • Please post your code inside your question – Pieter Goosen Jul 12 '15 at 11:13
  • @PieterGoosen added the code, plus visit the site , that will give you clear idea ca.unitysofts.com – Rohan Zakie Jul 12 '15 at 11:20
0

Paste this code along side the code given by you I have not tested the code but it should do the trick...

where you used this [blog1 items=1 cat=op-ed] replace this with this [blogtag items=1 tag=china]

  <?php
$queried_object = get_queried_object();
$term = $queried_object->name;
add_shortcode("blogtag", "blog_tag");



function blog_tag($atts, $content) {

    extract(shortcode_atts(array(

        "items" => 4,

        "tag" => null,

        "id" => null,

        "nav" => false,

        "order" => "desc",

        "orderby" => "DATE",

        "events" => null

    ), $atts));

    $order       = strtoupper($order);

    $items_count = 0;

    $items_src   = null;

    if ($id == null) {

        $query          = array(

            'orderby' => $orderby,

            'order' => $order,

            'posts_per_page' => $items,

            'tag' => $tag

        );

        $wp_query_event = new WP_Query($query);

    }

    $items_src .= '

<div id="short-one" class="fixed">';

    while ($wp_query_event->have_posts()):

        $wp_query_event->the_post();

        global $post;

        $image_id = get_post_thumbnail_id();

        $cover    = wp_get_attachment_image_src($image_id, 'short-one');

        $no_cover = get_template_directory_uri();

        $tag      = get_the_tags();

        $vimeo    = get_post_meta($post->ID, "post_vimeo", true);

        $youtube  = get_post_meta($post->ID, "post_youtube", true);

        $author   = get_the_author_meta('ID');

        $items_src .= '

        <div class="short-one-art">

                <div class="short-one-cover">';

        if ($vimeo or $youtube) {

            $items_src .= '<a href="' . get_permalink() . '"><div class="short-one-video"></div></a>';

        }

        $items_src .= '

                        <a href="' . get_permalink() . '">';

        if ($image_id) {

            $items_src .= '<img src="' . $cover[0] . '" alt="' . get_the_title() . '" />';

        } else {

            $items_src .= '<img src="' . $no_cover . '/images/no-cover/short-one.png" alt="no-cover" />';

        }

        $items_src .= '</a>

                        <div class="comment-bubble">

                                <span class="comment-count">' . get_comments_number() . '</span>

                        </div>';

        if ($tag != null) {

        } else {

            $items_src .= '            

                        <div class="slider-left-cat">' . $tag[0]->name . '</div>';

        }

        $items_src .= '</div>

                <h2><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>

                <div class="short-one-info">' . get_the_date('F jS, Y') . ' | by <a href="' . get_author_posts_url($author) . '">' . get_the_author() . '</a> | <a href="'.get_tag_link($tag[0]->term_id).'">'. $tag[0]->name .'</a></div>

                ' . get_excerpt(230) . '

        </div><!-- end .short-one-art -->';

    endwhile;

    wp_reset_query();

    $items_src .= '

</div><!-- end #short-one -->

';

    return $items_src;

}
  • it works perfect guru, you have taught me a new way of approach, appreciate that, may be i have last one or tow questions that i will ask in new post, but your help, gave me milage. thanks – Rohan Zakie Jul 12 '15 at 22:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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