• Resolved headlessspider

    (@headlessspider)


    hello,

    i’ve been looking for a tag/plugin that can list, in the sidebar, posts that i think i want highlighted so that they will always be in the sidebar.

    this is similar to the “highlight post” thingy in yahoo 360. i’ve thought about adding a category named “highlighted” but the problem there is that i want this list to be separate from all the other list.

    anyone has ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hmm. I’m thinking you can do something like this by making use of custom fields. Here’s what I suggest:

    1. Add a custom field key to each post you want highlighted. for originality we’ll call the key ‘highlight’ — :)

    2. Give a unique number for each ‘highlight’ value. We’ll use this for post ordering, so ‘1’ is displayed first, ‘2’ is second…I think you get the idea.

    3. Use this in your template to display the posts:

    <?php
    $customkey = 'highlight'; // set custom key

    global $wpdb;
    $highlighted = $wpdb->get_results("SELECT * FROM $wpdb->posts, $wpdb->postmeta WHERE ID = post_id AND meta_key = '$customkey' ORDER BY meta_value ASC");
    foreach($highlighted as $post) : setup_postdata($post);
    ?>

    ~”Loop” template tags and whatnot go here~

    <?php endforeach; ?>

    What you display or the formatting is up to you. Here’s an example which places them in a list, with titles as links to the posts:

    <ul>
    <li><h2>Highlighted posts:</h2>
    <ul>
    <?php
    $customkey = 'highlight'; // set custom key

    global $wpdb;
    $highlighted = $wpdb->get_results("SELECT * FROM $wpdb->posts, $wpdb->postmeta WHERE ID = post_id AND meta_key = '$customkey' ORDER BY meta_value ASC");
    foreach($highlighted as $post) : setup_postdata($post);
    ?>
    <li><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permalink to: <?php the_title(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>
    </li>
    </ul>

    Thread Starter headlessspider

    (@headlessspider)

    woah. ok. i’ll test this and report back. thanks!

    Thread Starter headlessspider

    (@headlessspider)

    i started to try out this suggestion but the widgets kind of got in the way. i was trying it out and, on a whim, i tried putting a couple of highlighted links in the text widget box. voila, it works. but i still have to put the title and the links in manually.

    i will be playing with this piece of code also but in another wp blog.

    thanks!

    NEVERMIND – fixed it!

    I can’t seem to get this to work. I used highlight as the custom key, and have used 1 and 2 as the value on two posts (to test it), but still nothing shows up on the site.

    https://www.civicyouth.org/wordpress/

    Should be showing up under Research Highlights in right hand sidebar

    Any help would be appreciated!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘highlighted posts in the sidebar’ is closed to new replies.