Note that there are some explanatory texts on larger screens.

plurals
  1. POExcluding Wordpress Posts From Being Displayed in Their Respective Category
    primarykey
    data
    text
    <p>Long title, I know :) But anyways, what I'm trying to do is hide a post from its respective category. So say I submit a post and file it under the news category, I want it to not show up in its respective category page, if need be. Weird request, I know.. </p> <p>The way I have went about doing this is creating a custom field called "hide" with any value, then I echo the CSS style for the div class "post" to <code>display:none</code>. Here is the PHP if statement:</p> <pre><code>&lt;?php } if($hide) { ?&gt; echo '&lt;style type="text/css"&gt; .post {display:none;} &lt;/style&gt;'; &lt;?php } ?&gt; </code></pre> <p>This successfully hides the div "post" when any value for the custom field "hide" is entered, but the problem is... it hides <strong>all</strong> my posts!! Because all my posts are being displayed under the div class "post" and the echoed css style is being applied to all the .post divs and not just the one I entered the custom field for.</p> <p>Looking at my Wordpress posts, each post has a seperate number and div value. Theoretically, I could manually type in the id for each div and hide each post once each post is entered, but that would take way too long. </p> <p>At this point, I honestly have no idea how to fix this issue so it hides only the post that I enter the custom field for. Any help would truely be appreciated! :)</p> <p>Update: I forgot to mention that I'm also using other custom fields to display the post.. here is how my full php code looks:</p> <pre><code>&lt;?php } if (is_category('audio')) { ?&gt; &lt;div class="entry-summary"&gt; &lt;?php if (has_post_thumbnail()){ ?&gt; &lt;?php if($audiohover == '5') { ?&gt; &lt;div class="view view-fifth"&gt; &lt;?php the_post_thumbnail(); ?&gt; &lt;div class="mask"&gt; &lt;a href="&lt;?php echo esc_url_raw( $url ); ?&gt;" class="info" target="_blank"&gt;&lt;img src="else" /&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php } elseif($audiohover == '6') { ?&gt; &lt;div class="view view-fifth"&gt; &lt;?php the_post_thumbnail(); ?&gt; &lt;div class="mask"&gt; &lt;a href="&lt;?php echo esc_url_raw( $url ); ?&gt;" class="info" target="_blank"&gt;&lt;img src="else" /&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php } elseif($audiohover == '4') { ?&gt; &lt;div class="view view-fifth"&gt; &lt;?php the_post_thumbnail(); ?&gt; &lt;div class="mask"&gt; &lt;a href="&lt;?php the_permalink(); ?&gt;?fromwhere=audio"" class="info"&gt;&lt;img src="img" /&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php } if($hide) { ?&gt; &lt;?php } ?&gt; &lt;?php } ?&gt; &lt;?php } ?&gt; </code></pre> <p><strong>Summary of What I want to Achieve: I want to select if a post will be displayed or not in its respective category page. Example: I post something under the News category. When I goto the news category page, I want to be able to chose if the post filed under the news category will be visible or not. My way of doing this as of right now is through custom fields. Read the question to see why it isn't working properly! :(</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload