Forum Replies Created

Viewing 15 replies - 106 through 120 (of 128 total)
  • Thread Starter dunkkan

    (@dunkkan)

    I’ve noticed an article belonging to several categories will show the ‘default’ no-image icon (?).

    I guess it must be the get_posts function, but I don’t know which array pass there. I cannot call for every possible category to prevent each combination : it would list a bunch of things.

    I need to sort just one category, which eventually will be combined with another.

    Please, anybody can help ?

    Thread Starter dunkkan

    (@dunkkan)

    Okay, there we go :

    <!-- starting the loop.
         we target one category
         and get just 3 posts of it -->
    <?php
     $lastposts = get_posts('category=38&numberposts=3');
     foreach($lastposts as $post) :
        setup_postdata($post);
    ?>
    <!-- a title for each of those 3 posts,
         permalinked -->
    <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
    <!-- detecting the attachment
         in the database,
         and sorting it -->
    <?php
    global $wpdb;
    $attachment_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_status = 'inherit' AND post_type='attachment' ORDER BY post_date DESC LIMIT 1");
    ?>
    <!-- printing our cool
         clickable thumb -->
    <a href="<?php the_permalink(); ?>"><?php echo get_attachment_icon($attachment_id); ?></a>
    <!-- closing the loop -->
    <?php endforeach; ?>

    If we want to repeat the same for another category in the same page, don’t forget to replace your <?php get_header(); ?> by a new <?php get_header(); rewind_posts(); ?> in the beggining of your template.

    Thread Starter dunkkan

    (@dunkkan)

    In this topic I think I found the solution.

    Thread Starter dunkkan

    (@dunkkan)

    Thanks pretty much

    I’m trying to set three posts like this (excerpts):

    thumb—–thumb—–thumb
    words—–words——words
    words—–words——words
    words—–words——words

    The code above only will show the first thumbnail for the first post.

    I use get_posts to set the multiple loops:

    <?php
     $posts = get_posts('numberposts=1&category=18');
     foreach($posts as $post) :
        setup_postdata($post);
     ?>
    <?php postimage('thumbnail'); ?>
    <?php the_excerpt(); ?>
    <?php endforeach; ?>

    In the second and third post I use an &offset=1 and &offset=2 respectively, which I add to the get_posts function.
    I’ve put as well the rewind_posts function at the begining of the template, so the three excerpts shows perfectly. But not the thumbs #2 and #3.

    I think I could fix it by arranging some arguments or arrays in the function.php, but I’m lost at this point. I tried to use the get_children, which requires once again some arguments I ignore.

    If anybody can provide any tip…

    By the way, I’m trying to set three posts like this (excerpts):

    thumb—–thumb—–thumb
    blabla—–blabla——blabla
    blabla—–blabla——blabla
    blabla—–blabla——blabla

    But the code avobe only shows the first thumbnail for the first post.

    I use this loop for the first post:

    <?php
     $posts = get_posts('numberposts=1&category=18');
     foreach($posts as $post) :
        setup_postdata($post);
     ?>
    <!-- the code to print the thumbnail -->
    <a href="<?php the_permalink() ?>"><?php
    $files = get_children("post_parent=$id&post_type=attachment&post_mime_type=image");
    if($files){
            $keys = array_keys($files);
            $num=$keys[0];
            $thumb=wp_get_attachment_thumb_url($num);
            print "<img src=$thumb class=fade>";
    }
    ?></a>
    <?php the_excerpt(); ?>
    <?php endforeach; ?>

    In the second and third post I use an &offset=1 and &offset=2 respectively which I add to the get_posts function. I have put as well the rewind_posts function at the begining of the template, so the three excerpts shows perfectly.

    Thanks for any tip.

    Thanks guys that was really useful.

    A tip for the begginers like me:

    If you wrapp the whole code with that <a href="<?php the_permalink() ?>"> thecodepostedabove </a> you make the thumbnail click to the post.

    Hey guys, it worked for me like a charm. I just created a functions.php file I didn’t have, and put there the first part of bechster code, then, in my index.php, where I need to show tiny excerpts (and instead of a classical <?php the_excerpt(); ?>), I pasted the second part of the code.

    I’m using the last WP version.

    Thread Starter dunkkan

    (@dunkkan)

    Well I’m thinking I’ll do the “not so perfect” solution, which is quite perfect as well. But if someone have some smart idea I’ll be checking it.

    Hi, there’s a wonderful plugin

    http://www.cnet.ro/wordpress/thumbnailforexcerpts/

    Thread Starter dunkkan

    (@dunkkan)

    Thanks guys for the support, I guess it was something related to my ftp uploader.

    Thread Starter dunkkan

    (@dunkkan)

    Thanks a lot Moshu,

    If I understand it well, this code in the header should do the work (I’m not sure at all about the php syntax):

    <?php if(!is_front_page()){ ?>
    
    <!-- the path for the library -->
    <script type="text/javascript" src="library/jquery-1.2.6.min.js"></script>
    
    <!-- a little script or script's path -->
    <script type="text/javascript">
    function mouseOver()
    {
    document.titre.src ="images/title2.png";
    }
    function mouseOut()
    {
    document.titre.src ="images/title.png";
    }
    </script>
    
    <!-- and several other scripts / script's paths here -->
    
    <?php } ?>

    Is it sure to go this way ?
    I mean, to save some bandwith, what it’s better: call for the script’s paths or write them all along the html ?

    Thread Starter dunkkan

    (@dunkkan)

    Well Thanks ! all is working now. My problem was I was missing the comma after the height: 54px ; – we are under too much screen radiation I guess, at least me, I could be this night still changing pixels to an open attribut without any external view… I’ve set the styles for the button as well, and it’s working like a charm. Thanks Evita for that feedback.

    Thread Starter dunkkan

    (@dunkkan)

    Hi Darran, sorry here it goes:

    #searchform {
    	width: 254px;
    	height: 54px
    	margin: 10px auto;
    	padding: 5px 3px;
    	text-align: center;
    	}
    
    #searchform #s {
    	width: 254px;
    	height: 54px
    	padding: 2px;
    	}
    
    #searchsubmit {
    	padding: 1px;
    	}

    The width reacts well, but there’s no response from the height.

    Then :

    <form method="get" id="searchform" action="<?php bloginfo('url'); ?>">
    <input id="s" type="text" onblur="if(this.value == '') {this.value = 'Search';}" onfocus="if(this.value == 'Search') {this.value = '';}" value="Search" name="s"/>
    <input type="submit" name="submit" value="Go" id="searchsubmit"/>
    </form>

    Maybe is impossible and every browser out there displays a standart line height which you cannot touch, but I remember have seen some search boxes quite big than the usual.

    Thanks to give it a look.

Viewing 15 replies - 106 through 120 (of 128 total)