Wordpress and Webdesign Forum go41 » WordPress Code Snippets

  1. Miklo
    Member

    Hello

    Wondered how I can change language on the date dispalyed.

    I also wonder how I can change what category the first two post on top of the drop down list show. I am not sure if that's called "drop-down list", but the posts that comes after the gallery. Would like to display other categories than those displayed after, and would like to play with the_excerpt. Where can I begin to change codes?

    Hope I make sense...

    Posted 8 months ago #
  2. The display of the date is set by <?php the_time('F jS, Y') ?> in some files of the theme. As there are many ways to format a time and date display please check here how to change:
    http://codex.wordpress.org/Template_Tags/the_time

    In German themes I use sometimes: <?php the_time('d.m.y') ?> to display: 03.12.09

    The "drop-down list" you talk about, do you mean the posts coming below the 'Browse Categories' section? This I would call the front-list as it is in a div id="front-list"

    This front-list shows you by default all posts older than the four posts you have in the slider. You could start to include or exclude categories there, BUT this is the index of your site and excluded categories will be excluded on subsequent pages too. To make pagination work on a setup like this is quite difficult.

    the_excerpt: in the slider (headslider.php) I use as replacement for the_excerpt this:

    <p><?php the_content_rss('', TRUE, '', 30);  ?><a href="<?php the_permalink() ?>" >read more</a></p>

    so if for example you replace <?php the_excerpt(); ?> in line 45 of index.php with the line above, the first two post in front-list will show 30 words and a 'read more' link.
    Changing the number 30 in that line to 40 will give you 40 words..

    Posted 8 months ago #
  3. Miklo
    Member

    Correct, it is the front list under categories I was talking about, sorry for the misinfo. What I do to exclude/include categories and select the number of posts for the whole list is

    query_posts("cat=-7,-1&paged=$page&offset=0&posts_per_page=16");

    But as you can see on the design, the first two posts are aligned differently, and I would like those two to show cat 7 and cat 1. No easy way to explain how to do this?

    The excerpt thing worked out greatly. Thank you very much!

    Posted 8 months ago #
  4. not easy to explain, I would insert a new query before the one you have already, try this:

    in index.php look for:
    div id="bottom" class="clearfloat"
    div id="front-list"

    and make place just below this.
    now insert the following code BEFORE this
    ..php if(is_paged()) { ..
    ..span class="breadcrumbs"......

    <!-- query for posts from two categories on first page only -->
    <?php if ( !is_paged()) { // comes only if is not paged ?>
    <?php $display_categories = array(1,7); }; // two category IDs to display one post each
    		foreach ($display_categories as $category) { ?>
    <?php query_posts("showposts=1&cat=$category") //one post per selected category ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="clearfloat">
    <div class="title"><h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2></div>
    <div class="spoiler">
    <?php	$values = get_post_custom_values("Image"); if (isset($values[0])) { ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=150&h=150&zc=1&q=80" alt="<?php the_title(); ?>" class="left" /></a>
    <?php } ?>
    <?php the_excerpt(); ?>
    </div>
    <div class="meta"><?php the_time('F jS, Y') ?><?php the_tags( ' | Tags: ', ', ', ' '); ?><?php if(function_exists('the_views')) { the_views(); } ?></div>
    </div><?php ?>
    <?php endwhile; ?>
    <?php } ?>
    <!-- end query for posts from two categories -->

    check if it's working, I will put it in the next free 'Arthemia Green' .. soon

    Posted 8 months ago #
  5. Miklo
    Member

    Really, really great!!! Worked like a charm!

    Thank you so much!

    Posted 8 months ago #
  6. no! not on second page, here slightly changed:

    <!-- query for posts from two categories on first page only -->
    <?php if ( !is_paged()) { // comes only if is not paged ?>
    <?php $display_categories = array(1,7); // insert the two category IDs to display one post each as featured
    		foreach ($display_categories as $category) { ?>
    <?php query_posts("showposts=1&cat=$category") //one post per selected category ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="clearfloat featposts">
    <div class="title"><h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2></div>
    <div class="spoiler">
    <?php	$values = get_post_custom_values("Image"); if (isset($values[0])) { ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=150&h=150&zc=1&q=80" alt="<?php the_title(); ?>" class="left" /></a>
    <?php } ?>
    <?php the_excerpt(); ?>
    </div>
    <div class="meta"><?php the_time('F jS, Y') ?><?php the_tags( ' | Tags: ', ', ', ' '); ?><?php if(function_exists('the_views')) { the_views(); } ?></div>
    </div><?php ?>
    <?php endwhile; ?>
    <?php } ?>
    <?php } ?>
    <!-- end query for posts from two categories -->

    Is your site to see somewhere?

    Posted 8 months ago #
  7. Miklo
    Member

    Well, the site is on http://duvet.no, but with Arras Theme. I am currently working on this from the back-end of my site, which uses Wordpress. When I have all the little tweaks I need, I will change it.

    EDIT: Does this work? http://duvet.no/?preview=1&template=arthemix-bronze&stylesheet=arthemix-bronze#top

    Had trouble with the gallery that is included with the theme, so I am thinking of using Featured Content Gallery plugin, but when I put the .php code, it doesn't seem to work. Maybe because the theme is not activated yet. So I put up a screenshot meanwhile.

    Posted 8 months ago #
  8. preview might work only for admin with a cookie.. I see Arras theme.

    to show a slider as on your site you could delete this stuff in headslider.php

    ul class="ui-tabs-nav"
    ...
    /ul

    this should just run the left side of it

    Posted 8 months ago #
  9. Miklo
    Member

    You can see a bit here:

    http://dump.no/files/8360519e8f6d/Screen_shot_2009-12-16_at_5.08.43_PM.png

    See how the two first post in the category "MP3" are shown before the rest are shown side by side? I want all post in "MP3" shown side by side. The new code you gave is shown at the top, which is great. But I would like for "MP3" to follow side by side instead of two first on top of each other before the rest.

    How do I do that?

    EDIT: More pics: http://dump.no/files/8360519e8f6d/New_site.zip

    Posted 8 months ago #
  10. I see - you create a mix of arthemia and Arthemix.

    to get rid of the two wide posts before the side by side ones, you have to delete something in index.php

    Start after this line and keep this line:

    <?php if ( $paged < 2 ) { ?>

    what you delete is from here (if post one and post two..) :

    <?php if (($i == 1) || ($i == 2)) { ?>
    ...
    </div><?php $i++; ?>

    Now comes this WHAT YOU MODIFY:

    <?php } else { ?>
    <?php if( $odd = $i%2 )

    There is no if - else anymore, so the else has to be removed but keep one bracket like this:

    <?php { ?>
    <?php if( $odd = $i%2 )

    Now it should look like you want...

    Posted 8 months ago #

RSS feed for this topic

Reply »

You must log in to post.

Join us! or log in (lost password?):