WordPress.org

Forums

Hack / Tutorial: Dynamic Sticky or adhesive (12 posts)

  1. clarke1866
    Member
    Posted 10 years ago #

    Greetings all,

    Thanks to the help of everyone here at these forums I have gotten a large part of my site customization done. Recently, I was reading about using multiple loops to do various things. Reading up, and asking the right questions (and most importantly, getting the right answers from this community) have led me to write a tutorial on how I created my own version of a sticky or adhesive post -- one that stays at the top of the index page.

    Essentially, it queries the DB twice: first looking for 1 post (the most recent) in the 'featured' category; and secondly, all posts except the post 'featured'. This allows the featured post to be put into multiple categories just like any other post could be, yet treats it as special until a new 'feature' post is published.

    Anyway, head on over to my site, MaxPower and see this post for a full explanation and demonstration. I would appreciate any comments or feature suggestions.

  2. Root
    Member
    Posted 10 years ago #

    That is very very useful. But I wonder if I might be permitted one small observation. For a first time user with no php experience at all the ideal would be a copy and paste solution. The codex is full of // do stuff; which is fine but then the guy asks what stuff. This can never be made too easy. But thanks for a great piece of work.

  3. kristin
    Member
    Posted 10 years ago #

    could you maybe post a example from your index.php? for those of us who don't know the codex that well it's a little confusing.

  4. clarke1866
    Member
    Posted 10 years ago #

    I would love too, but I am hesitant at this point because I have discovered that by having two or more loops, some plugins will stop working. I don't understand why just yet... the plugins do work, its just they only work on the very first loop. For me, this means that the keyword, meta, and technorati plugins don't funtion as I'd like them too.

    I have posted this question to brains here, so hopefully someone will give up an answer.

  5. kristin
    Member
    Posted 10 years ago #

    Sounds good. I stuck it in my template the way you have it on your site, but I kept getting some php errors so I figured I was missing something. Maybe it was just a conflict with a plugin that I'm using too.

  6. kristin
    Member
    Posted 10 years ago #

    I dont think thats the problem I'm having. Ive tried removing every plugin that runs in the loop and also deactivated every plugin 1 by 1 to see if it made a difference.

    I get an error : Parse error: parse error, unexpected $ in /home/wiphey/public_html/wp-content/themes/wiphey/index.php on line 77

    Here is the index.php for my template:
    http://www.wiphey.com/wp-content/themes/wiphey/index.txt

    If you have any ideas, let me know =)

  7. kristin
    Member
    Posted 10 years ago #

    I should add that line 77 is the get_footer(); line and theres nothing being called in the footer except for: bloginfo('name'); and bloginfo('comments_rss2_url');

  8. Jinsan
    Member
    Posted 10 years ago #

    excellent stuff, very intriguing read - I may use something like this in the future, but probably not now. Certainly something to keep in mind, and thanks for the breakdown

  9. clarke1866
    Member
    Posted 10 years ago #

    I just wrote this up, maybe it helps you out (I haven't looked yet, but will). Creating a dynamic sticky in Kubrick

  10. clarke1866
    Member
    Posted 10 years ago #

    I think you have something called twice, change this:

    Before:
    $my_query = new WP_Query('category_name=daily&showposts=1'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?>
    php if (have_posts()) : while (have_posts()) : the_post();

    After:
    $my_query = new WP_Query('category_name=daily&showposts=1'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID;

    Note that I got rid of ?php in order to post the code changes, I don't know how to post code as text yet, its a friggin mystery to me. The point is get rid of this first instance of "php if (have_posts()) : while (have_posts()) : the_post();"

  11. kristin
    Member
    Posted 10 years ago #

    yay! that worked. thanks alot :P

  12. laxidasical
    Member
    Posted 8 years ago #

    This hack broke my sidebar and put it under my main content! Any answers why? http://www.hinkleytalon.com

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags