chrisjb
Forum Replies Created
-
Thanks for replying Sébastien; really appreciate your help.
I tried re-saving permalinks and no luck. I also changed the permalink structure to the same as the site it does work on and still no luck.
I feel like it is something to do with comments because the URL loads and the comments for the next post but not the post (although I have comments on display: none).
I’ve made sure all the settings are exactly replicated on both sites but still no joy.
The files are exactly the same, so it must be a setting. Just not sure what it could be.
Thanks for the great plugin — absolutely great. I just need to figure out this bug.
Also, I had a great idea for another plugin you might be interested in (or as a development of this plugin):
Infinite scroll on paginated posts (https://en.support.wordpress.com/nextpage/).
I would really like this for two important reasons:
1. Decrease page load time (because the first page of the post is smaller so loads faster)
2. You can see what percentage of people read past a certain portion of the article. E.g. if you divide a post into 4 pages and you see 90% of readers don’t read past page 2, you know page 2 needs to be improved.Thanks for your help. Really appreciate it. I hope I can get it fixed.
Thanks,
ChrisThanks Nick,
We’re checking that out now.
Cheers,
ChrisForum: Hacks
In reply to: Adapt wp_list_categories to display popular categories based on post viewsThanks bcworkz,
That will order a list of categories by number of posts in each category. However I would like to order them by number of views for all the posts in each categories.
It seems like there is currently no published guide to achieving this available online.
You could do it using something like this:
And then pull the views data and use it in wp_list_categories.
I’ll have a look into this to see how it could be done.
Forum: Fixing WordPress
In reply to: How to add HTML markup to category single_cat_title Category TitleDoes anyone know the file to edit to enable html in the single_cat_title? It would be good to have an answered thread for future searchers.
Forum: Fixing WordPress
In reply to: How to add HTML markup to category single_cat_title Category TitleActually I am using the strong element to break the title into two lines using CSS. I’d also like the second line of the title to be in a larger font-size. I have written the CSS but not sure how to get the strong element into the title. Think I might have to edit an include file to prevent HTML stripping but I don’t know which file it would be.
Ah OK great thanks mitcho. I’ll have a look at the MySQL as I can access that. I will post an update once I have got it working correctly.
Hi mitcho,
I’m using the PHP method in this way:
related_posts (array ('exclude' => array (285,514)));
(same as above)
I have found the category IDs by hovering over the categories in WP-Admin Categories admin page and viewing the link that displays in the bottom left of my browser. Do you know if those are the term_taxonomy_ids?
It still does not seem to exclude those categories. I’ve also tried the Pool options in WP-admin and that doesn’t seem to work when I use the PHP method.
Do you have any idea what I might be doing wrong?
Thanks in advance and really great plugin by the way.
ChrisForum: Plugins
In reply to: Category Description ONLY On First Category PageI think I might have found this:
is_category()&&!is_paged()
I’ll try and see if it works.
Forum: Plugins
In reply to: Category Description ONLY On First Category PageI’m also looking for conditional for “category first page”. I have content displayed above the paginated content, which shouldn’t be displayed on category-name/2.
Did you find the answer to this eselby? I couldn’t find anything in the conditionals codex resource.
….resolved.
I really think this should be default functionality of the wp_link_pages (or easier to modify the default output to wrap html around each link rather than having them as lonely floating anchor elements in the abyss).
In the meantime you can use this to solve this problem. There is also a different class for the link on the first page of the paginated post so you can style that differently:
<?php $links = wp_link_pages(array( 'before' => '', 'after' => '', 'next_or_number' => 'next', 'link_before' => '', 'link_after' => '', 'nextpagelink' => __('next'), 'previouspagelink' => __('pre'), 'pagelink' => '%', 'echo' => 0) ); $nextLink = ""; $previousLink = ""; $linksArray = explode("pre", $links); if (count($linksArray) == 2) { $previousLink = '<li class = "previous-page">' . $linksArray[0] . 'Previous Page</a></li>'; $links = explode("</a>", $linksArray[1]); $links = $linksArray[1]; } $linksArray = explode("next", $links); if (count($linksArray) == 2) { $nextLink = '<li class = "next-page">' . $linksArray[0] . 'Next Page</a></li>'; $continueReading = '<li class = "next-page">' . $linksArray[0] . 'Continue reading</a></li>'; } // show top navigation only if any one of links are present if (!(($nextLink == "") && ($previousLink == ""))) { ?> <div class="post-navigation-top clearfix"> <small class="page-number"><?php global $page, $numpages; echo "<strong>$page</strong> of $numpages"; ?></small> <ul> <?= $previousLink ?> <?= $nextLink ?> </ul> </div> <?php } $firstPageClass = ""; //see if its first page if ($previousLink == "") { $firstPage = true; $nextLink = $continueReading; //add class to nav bottom $firstPageClass = " first-page"; } ?> <div class="entry-content"> <?php the_content(); ?> <?php if (!(($nextLink == "") && ($previousLink == ""))) { ?> <div class="post-navigation-bottom<?= $firstPageClass ?>"> <ul> <?= $previousLink ?> <?= $nextLink ?> </ul> </div> <?php } ?> </div> <!-- /.entry-content -->
I managed to fix this in the end. Had some issues as I wanted to be able to use videos in the slideshow as well + a few other tweaks. But hopefully this code will help others:
<?php $posts_array = get_posts(array('numberposts' => 3, 'category' => 101)); $active = ' active'; $slidecount = 1; ?> <div id="myCarousel" class="span8 carousel slide"> <div class="carousel-inner"> <? foreach ($posts_array as $car) { if (has_post_video($car->ID)) { echo '<div style="height:100%;width:100%;" class="item' . $active . ' vid" id="slide' . $slidecount . '">'; echo get_the_post_video($car->ID, '100%', '100%'); echo '</div>'; } else { $url = wp_get_attachment_url(get_post_thumbnail_id($car->ID)); $article_date = get_the_time('D d M'); $article_headline = get_the_title($car->ID); echo ' <div class="item' . $active . '" id="slide' . $slidecount . '"> <a href="' . get_permalink($car->ID) . '"> <div class="carousel-headline"> <span class="article-date">' . $article_date . '</span> <h2>' . $article_headline . '</h2> </div> <img src="' . $url . '"> </a> </div> '; } $slidecount++; $active = ''; } ?> </div> <div class="carousel-controls"> <a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a> <a class="right carousel-control" href="#myCarousel" data-slide="next">›</a> </div> </div> <!-- /#myCarousel --> <div class="span8 feature-headlines"> <ul class="clearfix"> <?php $divcount = 1; foreach ($posts_array as $car2) { $cat = get_the_category($car2->ID); $promo_headline = get_post_meta($car2->ID, 'promo_headline', true); echo '<li class="slide' . $divcount . '"><div>'; echo '<h3>' . '<a href="' . get_permalink($car2->ID) . '">' . $promo_headline . '</a></h3>'; for ($i = 1; $i <= 1; $i++) { if ($cat[0]->cat_name == 'Features') { echo '<p><a href="' . get_category_link($cat[1]->cat_ID) . '">' . $cat[1]->cat_name . '</a></p></div></li>'; } else { echo '<p><a href="' . get_category_link($cat[0]->cat_ID) . '">' . $cat[0]->cat_name . '</a></p></div></li>'; } } $divcount++; } ?>
In that code I have also used a custom field called “promo_headline”, which is a shorter version of the post title. This is useful if you want the full headline in the slideshow and a shorter version in ‘other bit’ (as above).
Unfortunately darkwarriorblake if you want to be able to do this you’ll have to edit the plugin, which means you will have problems updating. Hopefully the plugin author will continue to develop the plugin as it works really well apart from this problem and the problem of displaying most popular posts in the current category.
Hopefully this code will help you add category ids as classes to your lis:
$cid = get_the_category($p->id); $cidfull = "cat-item cat-item-" . $cid[0]->cat_ID; $data = array( 'title' => '<a data-cat="' . $cid[0]->cat_ID . '" href="' . $permalink . '" title="' . $title . '">' . $title_sub . '</a>', 'summary' => $excerpt, 'stats' => $stats, 'img' => $thumb, 'id' => $p->id, 'category' => $cidfull ); array_push($posts_data, $data); // PUTTING IT ALL TOGETHER if ($instance['markup']['custom_html']) { // build custom layout $classes = ""; foreach ($cid as $c) { $classes.="cat-item-".$c->cat_ID." "; } if ($instance['markup']['list']) { if ($instance['markup']['pattern']['active']) { $content .= "<li class=\"cat-item-list $classes cat-post-" . $p->id ."\" data-postid=\"".$p->id."\" data-cat=\"" . $cid[0]->cat_ID . "\">" . htmlspecialchars_decode($this->format_content($instance['markup']['pattern']['form'], $data, $instance['rating'])) . htmlspecialchars_decode($instance['markup']['post-end'], ENT_QUOTES) . "\n"; } else { $content .= "<li class=\"cat-item-list $classes cat-post-" . $p->id ."\" data-postid=\"".$p->id."\" data-cat=\"" . $cid[0]->cat_ID . "\">" . "{$thumb}<a href=\"{$permalink}\" title=\"{$title}\" class=\"wpp-post-title\">{$title_sub}</a> {$excerpt}{$stats}{$rating}" . htmlspecialchars_decode($instance['markup']['post-end'], ENT_QUOTES) . "\n"; } } else { if ($instance['markup']['pattern']['active']) { $content .= "<li class=\"cat-item $classes cat-post-" . $p->id ."\" data-postid=\"".$p->id."\" data-cat=\"" . $cid[0]->cat_ID . "\">" . htmlspecialchars_decode($this->format_content($instance['markup']['pattern']['form'], $data, $instance['rating'])) . htmlspecialchars_decode($instance['markup']['post-end'], ENT_QUOTES) . "\n"; } else { $content .= "<li class=\"cat-item $classes cat-post-" . $p->id ."\" data-postid=\"".$p->id."\" data-cat=\"" . $cid[0]->cat_ID . "\">" . "{$thumb}<a href=\"{$permalink}\" title=\"{$title}\" class=\"wpp-post-title\">{$title_sub}</a> {$excerpt}{$stats}{$rating}" . htmlspecialchars_decode($instance['markup']['post-end'], ENT_QUOTES) . "\n"; } } } else { // build regular layout $content .= "<li class=\"cat-item cat-item-" . $cid[0]->cat_ID . "\" data-cat=\"" . $cid[0]->cat_ID . "\">{$thumb}<a href=\"{$permalink}\" title=\"{$title}\" class=\"wpp-post-title\">{$title_sub}</a> {$excerpt}<span class=\"post-stats\">{$stats}</span>{$rating}</li>" . "\n"; } }
Forum: Plugins
In reply to: [User Photo] Display list of 8 user photos on home page, outside the loopUnfortunately the User Photo plugin didn’t work for this so in the end I stuck to good old Gravatar, which works perfectly. Here’s is the code I used in the end, with links to author pages as well:
<?php //display selected users $userids_to_display = array(11, 7, 12, 13, 5, 6, 9, 8); // wordpress user IDs to include $blogusers = get_users_of_blog(); if ($blogusers) { foreach ($blogusers as $bloguser) { if (in_array($bloguser->user_id, $userids_to_display)) { $author_url = get_author_posts_url($bloguser->user_id); $user = get_userdata($bloguser->user_id); echo '<div class="expert-author">'; echo '<a href='.$author_url.'>'; echo '<div class="thumbnail">' . get_avatar($user->ID) . '</div>'; echo '<h4>' . $user->user_firstname . ' ' . $user->user_lastname . '</h4></a>'; $args = array( 'author' => $user->ID, 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 1, 'caller_get_posts' => 1 ); $my_query = null; $my_query = new WP_Query($args); if ($my_query->have_posts()) { //echo 'List of Posts for ' . user->user_firstname . ' ' . $user->user_lastname; while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php echo get_post_meta($post->ID, 'promo_headline', true); ?></a></p> <?php endwhile; } wp_reset_query(); // Restore global post data stomped by the_post(). echo '</div>'; } } } ?>
In the end I used wp_nav_menu to solve this problem.
I can’t believe I didn’t think of that earlier. Now though I have to try to figure out how to display category images for each category link.