Viewing 4 replies - 1 through 4 (of 4 total)
  • Consider downloading and installing Otto’s PHP Code Widget.

    Then put code like this in one of those widgets:

    <?php
    $posts=get_posts('post_type=post&showposts=1');
    if ($posts) {
    foreach($posts as $post) {
    setup_postdata($post);
    ?>
    <p><?php the_time('m.d.y') ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
    <?php
    the_content();
    }
    }
    ?>

    Please remember to support our plugin authors by clicking on the Donate button there.

    Thread Starter cantgetusername

    (@cantgetusername)

    Tank you for that great idea. It almost works. But your code Has the title of the newest page und the permalink to the newest page but the content of the newest post.

    That seems to be a bit strange so far. Could anyone find the mistake and fix it?

    Thread Starter cantgetusername

    (@cantgetusername)

    My theme has the option to show defined pages in a sideparwidget. (more info box)

    My new Idea is to put this php-code onto a page and define this page in a more info box.

    Using the plugin exec-php now. Was able to exec the php code above in a page and it works in my more info box. Now I wonder how i can tell this php code to have the right title and how to enable the “more-tags in this php code. Ill check the archive.php. Maybe I find something there

    Thread Starter cantgetusername

    (@cantgetusername)

    solved it:

    <?php query_posts('orderby=id&order=dsc&showposts=1'); ?>
    
    <?php if (have_posts()) : the_post(); ?>
    <p><a href="<?php the_permalink() ?>" rel="bookmark"  style="text-decoration:none; font-size: 16px; color: black; line-height:20px;" title="Link zu <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
    <?php the_excerpt() ?>
    <?php endif; ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show Post in a Widget’ is closed to new replies.