danalydesign
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Meta Description/ExcerptAwesome! You ARE the man.
Forum: Fixing WordPress
In reply to: Meta Description/ExcerptThank you, sir. Now if I want to trim the meta down to only 160 characters from this code what would I do?
echo strip_tags(get_the_excerpt($post->ID));Forum: Fixing WordPress
In reply to: Get posts from category – exclude current postit’s returning the proper post id – I can’t get this thing to work at all.
Display all posts related to category but do not include the currently displayed post in the list:<ul> <?php $post_categories = wp_get_post_categories( $post->ID ); ?> <?php $query = array ( 'post_type' => 'community', 'category__in' => $post_categories, 'posts_per_page' => 5 ); ?> <?php $queryObject = new WP_Query($query); ?> <?php if ($queryObject->have_posts()) : while ($queryObject->have_posts()) : $queryObject->the_post(); ?> <li><a href="<?php echo get_permalink(); ?>"><?php if (strlen($post->post_title) > 22) { echo substr(the_title($before = '', $after = '', FALSE), 0, 22) . '...'; } else { the_title();} ?></a></li> <?php endwhile; else: ?> <li>No related resources found.</li> <?php endif; ?> <?php wp_reset_query(); ?> <li class="last"><i class="icon-circle-arrow-right"></i> <a href="/community/category/sleep/">View All Resources</a></li> </ul>Forum: Fixing WordPress
In reply to: Get posts from category – exclude current posta thought: would this have anything to do with the fact that I’m pulling from a sub category?
Forum: Fixing WordPress
In reply to: Hide code if no posts are found?keesiemeijer, no matter what anyone saysd about you – I know that you ARE the man! Thanks for keeping me sane!
Forum: Fixing WordPress
In reply to: Get posts from category – exclude current postis that ‘list module’ directly coded into single.php or done with a function or widget?
This is a chunk of code in my custom taxonomy single page: single-taxonomy.php
Forum: Fixing WordPress
In reply to: Get posts from category – exclude current postI used this
<?php $query = array ( 'post_type' => 'affiliates', 'affiliatetype' => 'apps', 'category__in' => $post_categories, 'posts_per_page' => 4, 'post__not_in' => array( $post->ID ) ); ?>Forum: Fixing WordPress
In reply to: Get posts from category – exclude current postI found this back 3 years ago on here:
<?php $yourcat = 373; // Stick the ID here and it'll be placed in the relevant places below. if( in_category( $yourcat ) ) : $my_query = new WP_Query(array( 'showposts' => 3, 'orderby' => 'rand', 'cat' => $yourcat, 'post__not_in' => array($post->ID) )); unset($yourcat); while ($my_query->have_posts()) : $my_query->the_post(); ?> <a href="<?php the_permalink(); ?>"><img src="<?php echo p75GetThumbnail($post->ID, 100, 100); ?>"></a> <?php endwhile; endif; ?>how could i incorporate this into my code:
<ul class="icons"> <?php $post_categories = wp_get_post_categories( $post->ID ); ?> <?php $query = array ( 'post_type' => 'articles', 'articletype' => 'news', 'category__in' => $post_categories, 'posts_per_page' => 4 ); ?> <?php $queryObject = new WP_Query($query); ?> <?php if ($queryObject->have_posts()) : while ($queryObject->have_posts()) : $queryObject->the_post(); ?> <li class="icon-file"><a href="/articles/<?php echo basename(get_permalink()); ?>/"><?php if (strlen($post->post_title) > 33) { echo substr(the_title($before = '', $after = '', FALSE), 0, 33) . '...'; } else { the_title();} ?> </a></li> <?php endwhile; else: ?> <li>No research articles found.</li> <?php endif; ?> <?php wp_reset_query(); ?> </ul>Forum: Fixing WordPress
In reply to: Get posts from category – exclude current postalchymyth, I appreciate your input but this does not seem to be working. When I’m viewing the single post, in my list module (which pulls the lates 4 post in the same category) this single post is still displaying as a link even though I’m viewing it. This is something that is happening on a global basis.
Forum: Fixing WordPress
In reply to: hide block of code if featured image existsThank you for your attention, James. Appreciated.
Forum: Fixing WordPress
In reply to: hide block of code if featured image existsActually jsut figured it out:
<?php if( has_post_thumbnail() ) { ?> CODE ABOVE GOESW HERE <?php } else { ?> NO CODE <?php } ?>Forum: Fixing WordPress
In reply to: hide block of code if featured image existsit displays the image and widget whether there is a featured image or not. I want to hide this entire block of code IF there is no featured image.
Forum: Fixing WordPress
In reply to: hide block of code if featured image existsNo, it’s the correct code. Running this code above produces the image and widget. No link as it is an internal website not open to the public.
Forum: Fixing WordPress
In reply to: hide block of code if featured image existsThis block of code basically displays an image and a widget. If there is no featured thumbnail, we want to hide this vblock of code so that the content (text) from the post moves up directly under the title.
Forum: Fixing WordPress
In reply to: hide block of code if featured image existsyes, our main website