Webreaper
Forum Replies Created
-
Tried changing it to:
$plant_shortcode .= '<p>'. get_the_excerpt( $post->ID ) .'</p>';
No effect, unfortunately.
Funnily enough, I only added the setup_postdata() line to try and fix the problem. Removing it has zero effect, unfortunately (but I’ve removed it all the same).
That doesn’t have any effect either.
What I’d really like to do is understand what is causing the link to break, and fix it, rather than trying to add additional code to try and work around the problem. It seems to me like the loop in my code is a pretty standard thing that must have been written hundreds of times before. ??
What looks perfect to you?
Here’s the page with the issue; WP Cache has been deleted, but it’s still showing the wrong ‘continue reading’ links.
https://www.pumpkinbeth.com/2017/04/white-terrarium-planting-list/
If you were referring to https://www.pumpkinbeth.com/plants, that’s a page, not a post, and has always worked correctly, as I specified in my OP.
Thanks. Unfortunately that hasn’t had any effect.
Forum: Plugins
In reply to: Fix for get_the_excerpt having the wrong Read More linksBizarrely, this appears to have fixed itself without me doing anything. I guess there was either a bug in WordPress or in one of the plugins I use, and somebody fixed it. Yay!
For my solution, putting it in a sidebar won’t work – it has to be in a particular page, because it uses the current page title to automatically find all other posts that contain the current page title within them, and build the list. This won’t work on a page where there are a number of articles.
You really need to consider how you want this to automatically generate the list of links. By using the title of the plant taxonomy pages, mine finds all references to plants with that name (e.g., on the page titled “Daffodil”, it will list all pages that contain the word “Daffodil”). Unless you can come up with a process like that, you’ll struggle to find one that does it automatically. It may be easier to find a plugin/shortcode that will (for example) list all pages that fall under a particular tag, or category, and approach the problem that way.
You’ll need to modify this to suit your own needs, it won’t just work out of the box, as it relies on a custom taxonomy. So in this case, it’ll only display the list for articles of post type ‘plants_list’.
If you’re not using custom taxonomies, the best way would be to turn this into a shortcode, and apply it then on any pages where you want this list to appear.
Forum: Plugins
In reply to: [The Events Calendar] Showing the event date on the search templateQuick update: I managed to solve this by:
1. Turning off breadcrumbs for the Happenstance theme I was using (which stopped the post-date being displayed in the search results.
2. Adding the event date to the excerpt, by adding this filter:function search_event_date_filter( $content ) { global $post; if( 'tribe_events' == $post->post_type && is_search() && ! is_single() ) { $custom_content = ''; $custom_content = '<ul><li>Event Date: <strong>' . tribe_get_start_date() . '</strong></li></ul>'; if( ! empty( $content ) ) $custom_content .= $content; return $custom_content; } return $content; } add_filter( 'the_content', 'search_event_date_filter', 11 );
Hope this helps anyone else who needs this functionality.
- This reply was modified 8 years, 3 months ago by Webreaper.
Forum: Plugins
In reply to: [The Events Calendar] Showing the event date on the search templateThanks, that’s what I was looking for. I’ll have to see if I can put together a filter that does this. Might be a good idea as a future enhancement for the plugin.
If I get something working, I’ll post back here.
Forum: Plugins
In reply to: [The Events Calendar] Showing the event date on the search templateHi Caroline,
There is no problem in the plugin or conflict with the theme. I’m looking to change the template in used by the search results. Also, disabling all of my plugins and switching to another theme is, as you can imagine, a huge amount of work and will likely break my entire site, which I can’t do in production.
Perhaps you can confirm to me whether the plugin is designed to display the event start date in the search results template first, and then if not, explain to me how I can change this?
Bit disappointed that I’ve waited all week for your response on ‘Support Wednesday’ and then just get this response to my post. Did you actually read my question?
Mark
Quick update to this, for people who might be interested, I fixed it by knocking up my own plugin which implements this filter:
function plant_articles_filter( $content ) { global $post; if( 'plant_lists' == $post->post_type && ! is_search() && is_single() ) { // stuff that loads when the shortcode is called goes here $current_title = get_the_title(); $currentID = get_the_ID(); $search_term = html_entity_decode($current_title, ENT_QUOTES); $search_one = new WP_Query(array( 'order' => 'ASC', 'orderby' => 'title', 's' => $search_term, 'post_status' => null, 'nopaging' => 1, 'post__not_in' => array($currentID), 'posts_per_page' => -10)); $search_term = preg_replace("/[^A-Za-z ]/", '', $current_title); $search_two = new WP_Query(array( 'order' => 'ASC', 'orderby' => 'title', 's' => $search_term, 'post_status' => null, 'nopaging' => 1, 'post__not_in' => array($currentID), 'posts_per_page' => -10)); $search_three = new WP_Query(array( 'order' => 'ASC', 'orderby' => 'title', 's' => $current_title, 'post_status' => null, 'nopaging' => 1, 'post__not_in' => array($currentID), 'posts_per_page' => -10)); $search_articles = new WP_Query(); $unique = array_unique(array_merge( $search_one->posts, $search_two->posts, $search_three->posts ), SORT_REGULAR); $search_articles->posts = $unique; $search_articles->post_count = count( $unique ); $title_search_results = '<h3>Articles that mention ' . $current_title . ':</h3><ul>'; $posts_count = 0; while($search_articles->have_posts()): $search_articles->the_post(); if( get_permalink() != '' && get_the_title() != '' ) { $posts_count++; $title_search_results .= '<li><a href="' . get_permalink() . '">' . get_the_title(). '</a></li>'; } endwhile; if( $posts_count == 0 ) { $title_search_results = ''; } else { $title_search_results .= '</ul>'; } wp_reset_query(); $content .= $title_search_results; } return $content; } add_filter( 'the_content', 'plant_articles_filter', 0 );
Works a treat – giving a dynamic bulleted list of articles based on a search on the current article title.
You can see an example here: https://www.pumpkinbeth.com/plants/lathyrus-odoratus-naomi-nazareth/
Hope this helps somebody else in future. ??
It’s an easy fix, which has been outlined several times in the thread already.
Thanks, the posts-to-posts plugin looks like it’ll give me exactly what I need. LOL @ #3. ??
Just seen the update above about the fix.
I’ve just downloaded it, FTP’d into my site, uploaded the new version, and copied it into wp-content/plugins/the-event-calendar, and my site is back up and running again.
Thanks for the quick turnaround!