• Hi to all,

    i have to resolve a tricky situation and i’m trying to follow differnt way s without arriving a real solution.

    In the wordpress frontend… i cycle the last 20 post_type. I have post, attachment and 3 custom type. Now I’d like to associate for each type of post an icon before the title of the post to discriminate the type of posts.

    Now i’d like to create a sort of condition like this…
    If is post then associate this immage… and so on… And then create an img tag before The_title in content.php

    I’m searching some wp functions: wp query for example but i don’t knwo how to use it correctly.

    Get_post_thumb isn’t a good way because i don’t want to create a new field for each post… but create the loop only with codes and a folder that contains only this icons.

    Is it possbile? It’s from this morning i look for a solution

    Thanks very much…

Viewing 2 replies - 1 through 2 (of 2 total)
  • hi.
    you mean you need this to be an option of a theme?

    if not, something like this :

    <?php if (have_posts()) : while (have_posts()) : the_post();
    $post_types = array('1_type', '2_type', '3_type');
    foreach ( $post_types as $type ) {
    if( get_post_type() == $type ) {
    $icon = '<img src="'. get_bloginfo('template_directory') .'/images/'. $type . '_icon.png ';
       } echo $icon;
    }
     the_title(); // and your normal loop
    ?>

    name your icons – myPostType_icon.png

    Thread Starter queengab

    (@queengab)

    Thakns for your support,

    I resolved in other way…

    <p class=”<?php print get_post_type(); ?>” /></p></span>

    Css class

    .entry-type .post {

    float: left;
    background: url(images/blog_icon_32.png) no-repeat;
    height: 32px;
    width: 32px;
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Insert an icon near each post_type title’ is closed to new replies.