Michelle R. Wood
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Related posts with more than one tag in custom taxonomyFor anyone who cares, I was able to get the desired result by inserting a break in my if statement:
$terms = get_the_terms($post->id, [taxonomy]); foreach ($terms as $term) { if($term->parent != 0) { $args=array([taxonomy] => $term->name, 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 1, 'orderby' => name, 'order' => 'ASC'); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <h3><?php the_title(); ?></h3> <?php if ( has_post_thumbnail() ) { the_post_thumbnail(array(100,100)); } ?> <p><?php the_excerpt(); ?></p> <?php endwhile; break; } wp_reset_query(); } }
Probably not the exact WordPress way to get this done, but it works.
Forum: Fixing WordPress
In reply to: Related posts with more than one tag in custom taxonomyWell, I thought your code worked for me … instead it showed the latest post regardless of term. I’ll keep working on it.
Forum: Fixing WordPress
In reply to: Related posts with more than one tag in custom taxonomyWow … I had the exact opposite problem. I wanted to get only 1 term from a custom taxonomy and was getting all of them. I used your code and it solved my problem.
I don’t know if you ever solved this issue, but here’s how I was getting all the terms:
$terms = get_the_terms($post->id, [taxonomy]); foreach ($terms as $term) { if($term->parent != 0) { $args=array([taxonomy] => $term->name, 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 1, 'orderby' => name, 'order' => 'ASC'); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <h3><?php the_title(); ?></h3> <?php if ( has_post_thumbnail() ) { the_post_thumbnail(array(100,100)); } ?> <p><?php the_excerpt(); ?></p> <?php endwhile; } wp_reset_query(); } }
Forum: Plugins
In reply to: [Plugin: Types] Rewrite URL w/o slugNew problem (but related): when making an edit to a custom post type post, the url changes from:
[sitename].com/[custom-page-title]
to
[sitename].com/[custom-page-title]-2
This same renaming process happens if you delete a custom post type post and recreate it. Delete the post twice and recreate it, you get
[sitename].com/[custom-page-title]-3
This behavior occurs regardless of whether the “Remove slug from custom post type” plugin is activated.
Sean, I can affirm that your solution works. Actually, I can publish the custom post type, click anywhere else in the site, than return to the url and get it to show up. Thanks for doing all the digging into the code: when I have some leisure (read: at home time), I’ll experiment further to try to find a solution.
Forum: Plugins
In reply to: [Plugin: Types] Rewrite URL w/o slugFor any true believers that have followed my tale so far, there is a bug in the “Remove slug from custom post type” plugin. Every time you go to add a new custom post type post, an error message will announce
Remove Slug Custom post type error! .htaccess is not writable, please add following lines to complete your installation: RewriteRule ^wp-types-group/(.+)$ /$1 [R=301,L] RewriteRule ^services/(.+)$ /$1 [R=301,L] RewriteRule ^/(.+)$ /$1 [R=301,L]
This error message is in bright red, so hard to miss (all it needs is “Danger Will Robinson!”) When you publish your post and click View, you will get a 404 error.
But fear not true believer: this error message is lying. Simply click anywhere else, than try to go back to your page. Voila, like magic, your page points to the correct directory. No need to add anything or change your .htaccess file.
You can read more about the reasons behind the bug at this thread. For now, it appears an unavoidable messy blight on an otherwise bright solution.
Addendum: check out the discussion on this thread for more details on this problem.
Alan: Unfortunately there seems to be a problem with your fix (which seems to be the only fix for this problem) and the Types plugin. I can remove these lines, but whenever I click “Add New” for my new custom content type the lines come back.
Also, contrariwise, clicking “Add New” under my custom content type shows an error message that prompts me to remove these lines.
Forum: Plugins
In reply to: [Plugin: Types] Rewrite URL w/o slugI found success by visiting the Types support forum and looking at the answer to this question (How to remove Post Type slug from permalinks): what I want requires an extra plugin.
Installing Remove slug from custom post type allows me to get the url I want.
That being said, this behavior should really be address in the help text and/or documentation for Types, since I imagine there are others who want a similar url structure for their site. I fortunately had the luxury of using work time to find a fix: the average user may not.
Forum: Plugins
In reply to: [Plugin: Types] Rewrite URL w/o slugOK, getting closer to the answer. Under Advanced Settings, choose “Use a custom URL format” and in the space provided type “/”. That way you will have the url permalink:
[sitename].com/[custom-page-title]
However, when I click “View Services” I get a 404 Error. Why should that be the case when any other custom url renders a correct page? Also, even if this trick had worked, it would still be a bug since my site’s permalink settings are to render all pages as “post name,” whereas choosing “Use the normal WordPress URL logic” under custom post type renders “[sitename].com/[slug]/[custom-page-title]”.