How to make classes for posts?

Use ‘post_class‘ for custom CSS per post. An example with 3 variations (only use 1): <div id=”post-<?php the_ID(); ?>” class=”red box” ?>> //idea 1 <div id=”post-<?php the_ID(); ?>” <?php post_class(‘box-color’); ?>> //idea 2 <div id=”box-color” <?php post_class(); ?>> //idea 3 <h3>Header</h3> Content </div> To be able to choose a color in the post, use a … Read more

Are private posts visible to search engines?

Search engines SHOULD respect the industry standard robots.txt file which you could use to block access to a post type. Such as blocking access to anything under example.com/deals. You could also go above and beyond and check the $_SERVER[‘HTTP_USER_AGENT’] for bots. Something like: $bot_list = array(“Teoma”, “alexa”, “froogle”, “Gigabot”, “inktomi”, “looksmart”, “URL_Spider_SQL”, “Firefly”, “NationalDirectory”, “Ask … Read more

Add Word Limit to Posts

You can limit is through a filter on the_content For example (in functions.php): add_filter(“the_content”, “Content_Filter_Custom”); function Content_Filter_Custom($content) { // return a subset of it return substr($content, 0, 300); }

WordPress blog or WordPress website

This is a rather clean-cut answer in my opinion, but each to their own and of course there will be varying opinions on this. The WordPress.com blog hosting service offers one major feature that self-hosted installations managed by WordPress newbies don’t have: great security. It’s no secret that a self-hosted WordPress installation can be a … Read more

Which post does a taxonomy term belongs to?

You could do it using the term_link filter. Something roughly as follows: function my_term_link($termlink, $term, $taxonomy) { global $post; if ($taxonomy == ‘my-custom-taxonomy’) { return get_permalink( $post->ID ) . ‘#’ . $term->term_id; } } while ( $programtype->have_posts() ) : $programtype->the_post(); $terms = get_the_terms( $post->ID, ‘my-custom-taxonomy’ ); add_filter(‘term_link’, ‘my_term_link’, 10, 3); foreach ($terms as $term) { … Read more

get_post_type on post.php

Why can’t you just globalize $post and then get the post type? e.g. <?php global $post; $post_type = get_post_type( $post->ID ); ?> In what context are you placing this code? In a metabox callback, or what? (Also: why are you using $_GET data?)

Allow non-logged in users to see a future post after clicking on a list of future posts

Try this: $my_query = new WP_Query(array( ‘post_status’ => ‘future’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 1, )); while ($my_query->have_posts()) { $my_query->the_post(); the_date(); echo ‘ – ‘; the_title(); } wp_reset_postdata(); or this: http://wordpress.org/extend/plugins/show-future-posts-on-single-post/

Category Foreach keeps looping?

<?php $cats = get_categories(‘child_of=”.get_query_var(“cat’)); foreach ($cats as $cat) : $args = array( ‘posts_per_page’ => 3, // max number of post per category ‘category__in’ => array($cat->term_id) ); $my_query = new WP_Query($args); if ($my_query->have_posts()) : echo ‘<h3>’.$cat->name.'</h3>’; while ($my_query->have_posts()) : $my_query->the_post(); ?> <?php /*general loop output; for instance: */ ?> <a href=”https://wordpress.stackexchange.com/questions/42272/<?php the_permalink() ?>”><?php the_title(); ?></a> <br … Read more