Skip to content
This repository

Exclude currently displayed post #8

Merged
merged 1 commit into from almost 2 years ago

2 participants

Dolores Ruiz Funes Torres Fernando Briano
Dolores Ruiz Funes Torres

This is the solution I've implemented for - http://goo.gl/50fJi , same problem as kelley's pull request (thks for his help).
Rough and ready.

Fernando Briano picandocodigo merged commit 9a397cd into from April 18, 2012
Fernando Briano picandocodigo closed this April 18, 2012
Fernando Briano picandocodigo referenced this pull request from a commit April 19, 2012
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 17, 2012
Dolores Ruiz Funes Torres Extend excludeposts to exclude current post 9a397cd
This page is out of date. Refresh to see the latest.
16  include/CatList.php
@@ -35,7 +35,12 @@ private function set_lcp_parameters(){
35 35
         ));
36 36
         
37 37
         //Exclude
38  
-        if(isset($this->params['excludeposts']) && $this->params['excludeposts'] != '0'): $args['exclude'] = $this->params['excludeposts']; endif;
  38
+        if(isset($this->params['excludeposts']) && $this->params['excludeposts'] != '0'):
  39
+        	$args['exclude'] = $this->params['excludeposts']; 
  40
+			if (strpos($args['exclude'],'this')!==false) {
  41
+				$args['exclude']=$args['exclude']. ",".$this->lcp_get_current_post_id();
  42
+			}
  43
+        endif;
39 44
         
40 45
         // Post type and post parent:
41 46
         if(isset($this->params['post_type']) && $this->params['post_type'] != '0'): $args['post_type'] = $this->params['post_type']; endif;
@@ -92,7 +97,11 @@ public function lcp_get_current_category(){
92 97
         $categories = get_the_category($post->ID);
93 98
         return $categories[0]->cat_ID;
94 99
     }
95  
-    
  100
+	
  101
+	private function lcp_get_current_post_id(){
  102
+	    global $post;
  103
+		return $post->ID;    
  104
+	 }
96 105
     /**
97 106
      * Get the category id from its name
98 107
      * by Eric Celeste / http://eric.clst.org
@@ -123,8 +132,7 @@ public function get_category_link(){
123 132
         if($this->params['catlink'] == 'yes' && $this->lcp_category_id != 0){
124 133
             $cat_link = get_category_link($this->lcp_category_id);
125 134
             $cat_title = get_cat_name($this->lcp_category_id);
126  
-            return '<a href="' . $cat_link . '" title="' . $cat_title . '">' .
127  
-                   ($this->params['catlink_string'] !== '' ? $this->params['catlink_string'] : $cat_title) . '</a>';
  135
+            return '<a href="' . $cat_link . '" title="' . $cat_title . '">' . $cat_title . '</a>';
128 136
         } else {
129 137
             return null;
130 138
         }
2  readme.txt
@@ -94,7 +94,7 @@ You can use the *categorypage* parameter to make it detect the category id of th
94 94
 
95 95
 * **excerpt_size** - Set the number of characters to display from the excerpt. Default is 255. Eg: `excerpt_size = 300`
96 96
 
97  
-* **excludeposts** - IDs of posts to exclude from the list. Ex: [catlist excludeposts=12,52,37]
  97
+* **excludeposts** - IDs of posts to exclude from the list. Use 'this' to exclude the current post. Ex: [catlist excludeposts=this,12,52,37]
98 98
 
99 99
 * **offset** - You can displace or pass over one or more initial posts which would normally be collected by your query through the use of the offset parameter.
100 100
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.