Current User: Guest
Please consider registering

 
Search Forums:


 




Using Inline Comments Outside "The Loop"

Post

tombyrnes - Member

11:07 pm - July 27, 2009

posts 4

 
1

Aaron,

Love your work! Really useful stuff and I will be a donor shortly. I have 2 quickish questions:

1. I wish to use the inline comments feature outside of the loop. I am using the "Inline Posts" plugin to generate one or so pages that are essentially "pages of posts". (ie the page consits of some introduction and then some directives to include post n, post m, post x etc). The code for this executes outside the loop. I have actually got your inline comments working by adding code to that plugin's main function to generate the html just as you do within the loop. The lines of PHP below build up the requisite html in the variable $showcomments and then that variable gets inserted in the appropriate place in the output. ($postId has been set up beforehand):

-------------------------------------------------------------------------------------------------------------

       $showcomments = '<a href="'.get_permalink($postId).'#comments" id="awpcomments_link_'.$postId.'" class="comments_link" onclick="aWP.doit({\'id\': \''.$postId.'\', \'type\': \'comments\'});  return false;" rel="nofollow">Show Comments ('.get_comments_number($postId).')</a>';
                $showcomments = $showcomments.'<div id="awpcomments_'.$postId.'" class="awpcomments" style="display:none;"></div>'  ;
                $showcomments = $showcomments.'<div id="awpcommentform_'.$postId.'" class="commentform" style="display:none;"></div>'  ;

------------------------------------------------------------------------------------------------------------------------------

(a) So it is working but I would prefer not to have to hack it like this. Is there a better way?

(b) Maybe there's a better approach to getting a page of posts than the above plugin? Any suggestions appreciated.


2. With the inline posts feature, I cannot see the html for the "hide 'postname'" link. I just wish to apply some CSS to it. Can you tell me the ID or class of this link?


Thanks heaps.


Tom

Aaron - Admin

2:56 pm - July 29, 2009

posts 382

 
2

Sorry for the short answer, but the easiest way is to use the wordpress functions. If you use the function setup_postdata() on any post query, it will act as the loop and you can use normal loop functions.

EG:

  1. <?php
  2. $lastposts = get_posts('numberposts=3');
  3. foreach($lastposts as $post) {
  4. setup_postdata($post);
  5. ?>
  6. <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
  7. <?php the_content(); ?>
  8. <?php } ?>

Many of the CSS classes AWP uses can be found here. The one you want is: post_content_link_hide

tombyrnes - Member

8:02 pm - July 29, 2009

posts 4

 
3

Aaron,


Wow thats really useful! You are a prince, Aaron, for taking the time to steer me in the right direction. Much appreciated.


tom



Reply to Topic: Using Inline Comments Outside "The Loop"

Name (Required):

EMail (Required):

Website):

Topic Reply:

HTML Editor
Save New PostSmileysOptions

Guest URL (required)

Math Required!
What is the sum of:
9 + 7
   

 
Confused Cool Cry Embarassed Frown Kiss Laugh Smile Surprised Wink Yell

 
 

About the Ajaxed WordPress forum

Most Users Ever Online:

35


Currently Online:

7 Guests

Forum Stats:

Groups: 1

Forums: 3

Topics: 186

Posts: 487

Membership:

There are 1177 Members

There have been 149 Guests

There is 1 Admin

There are 0 Moderators

Top Posters:

jakemc - 5

fromgrannie - 5

flash - 4

BAM - 4

Siam - 4

tombyrnes - 4

Administrators: Aaron (382 Posts)