wrimomatt
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Custom Order Related PagesPosting my solution if anyone has a similar need or if anyone thinks of a more elegant solution (I’m sure there is one). I would love for someone to come up with a way to make this happen in one template instead of one for each term:
1. created a template file for each of the taxonomy terms in the CPT from a clone of the main CPT template (e.g. single-cpt-term1.php, single-cpt-term2.php, etc.).
2. added meta boxes to the CPT to assign a value for each of the terms
3. ordered by the meta value in each of the individual term templates<?php //get the post's assignment $custom_terms = wp_get_post_terms($post->ID, 'your_custom_taxonomy'); if( $custom_terms ){ // going to hold our tax_query params $tax_query = array(); // add the relation parameter if( count( $custom_terms > 1 ) ) $tax_query['relation'] = 'OR' ; // loop through assignments and build a tax query foreach( $custom_terms as $custom_term ) { $tax_query[] = array( 'taxonomy' => 'your_custom_taxonomy', 'field' => 'slug', 'terms' => $custom_term->slug, ); } // put all the WP_Query args together $args = array( 'post_type' => 'your_custom_posttype', 'posts_per_page' => 6, 'meta_key' => 'your_metakey', 'order' => 'ASC', 'orderby' => 'meta_value_num', 'post__not_in' => array( get_the_ID() ), // Exclude current post 'tax_query' => $tax_query ); // finally run the query $loop = new WP_Query($args); if( $loop->have_posts() ) { while( $loop->have_posts() ) : $loop->the_post(); ?> <!-- YOUR CONTENT HERE --> <?php endwhile; } wp_reset_query(); }?>
Forum: Plugins
In reply to: [Multiple Featured Images] How to get URL to be a background image of a DIVRealize this is an old post, but thought I’d mention that I accomplished this using inline styles virtually identical to yours. The editor styles of this forum might have altered your code, but when I tried using your code both the single and double quotes were smart quotes, and I had to remove and replace them in my text editor, but after that your code worked for me.
FWIW here’s the code I use that works.
style="background: url(<?php echo kdmfi_get_featured_image_src( 'featured-image-2', 'full' ); ?> ) no-repeat;background-position:center center;background-size:cover;"
All that to say the issue might be somewhere else in your template.
Forum: Developing with WordPress
In reply to: automatically include parent w/ child custom taxonomyNevermind, the rewrite needs an additional nudge, apparently. All is well
'rewrite' => array( 'slug' => 'prettyname', 'hierarchical' => true ),
Forum: Developing with WordPress
In reply to: automatically include parent w/ child custom taxonomyMy parents terms are not showing up in the URL of the child terms. So if I go to the URL “/cityname” it’s not preceded by the “statename”. If I manually enter the statename in the URL it DOES show all the cities, but the individual cities lose the statename in their URL.
I’ve got hierarchical as true what else might I be missing? Thanks for any help.
Forum: Developing with WordPress
In reply to: automatically include parent w/ child custom taxonomyI love that you ended “I don’t really have a good answer,” when you gave an extremely thorough answer. This was very helpful. The redundancy is minor I think, compared to the potential issues created by trying to eliminate them. I did think about multiple town names, but only to rule out using two taxonomies (one for state, one for city). It also occurred to me from your explanation, that the full address will have an abbreviation, but I’d want the taxonomy to have the full state spelled out because it’s likely better for SEO.
Anyway, big thanks.
- This reply was modified 7 years, 6 months ago by wrimomatt.
Forum: Themes and Templates
In reply to: if meta value selectedokie dokie. So, if anyone else finds this and needs to do the same thing inside a loop, this is what worked. If you think the code can be improved upon, chime in.
<?php if('select-value#1' == get_post_meta($post->ID,'select-name', true)): ?> DO THIS THING <?php else: ?> DO THIS THING INSTEAD <?php endif; ?>
Forum: Themes and Templates
In reply to: How to Make Logo BiggerAgreed on that Tahoe, Theme author is the best place to start. Since original post referenced a lot of customization to the stylesheet I figured they were already all-in on tweaking.
Forum: Themes and Templates
In reply to: How to Make Logo BiggerIn the header you could put something like:
.logo .custom-logo-link img {width:25%;}
in there, but I’ll bet your Theme has a size set for the image you upload into that spot, so you’d just be stretching the small image into a bigger space (which looks grainy that way).The footer is a tight fit with those 4 columns, so there’s a limit to the tweaking. You could remove the margin and padding to beef it up a little, and then make the image fill up what space you have there, but again, the Theme might make the image grainy.
.footerlogo {margin:0;padding:0;text-align:left;width:100%;} .footerlogo img {width:100%;}
Forum: Themes and Templates
In reply to: Add a read more link on excerptsShould be in the template that displays your posts, which is usually single.php. That template might tie into another too, sometimes called content.php, or whatever the Theme decided to call it. The name of the file for that other template though should be referenced in your single.php template.
If you use excerpts on any other templates (like archive pages or search pages) you should be able to swap out the above code anywhere you find <?php the_excerpt(); ?>
If the excerpt is being automatically generated by the theme though the solution will be different. You got a link to your site?
Forum: Themes and Templates
In reply to: Add a read more link on excerptsI’m not sure about the Divi Theme, but this is a well-worn snippet that has worked for me in several different themes. Your mileage may vary, but might be a starting point.
To be used in place of <?php the_excerpt(); ?>
<?php $excerpt = get_the_excerpt(); $output = '<p>'.$excerpt.' <a href="'.get_permalink().'"><br />READ MORE ></a></p>'; echo $output; ?>
Forum: Hacks
In reply to: display custom meta data on any theme?thanks!
Forum: Fixing WordPress
In reply to: User Menu link to a Custom TaxonomyIf anyone else has this problem in the future:
wow, after lots of digging I found a very vital piece of code that was missing from my custom post type declaration:
'has_archive' => true,
Once that’s in the mix everything else behaves as expected ??
Forum: Fixing WordPress
In reply to: User Menu link to a Custom TaxonomyI have one set up for the custom taxonomy, but not for the specific terms. I want to create a template that will work for an infinite number of terms. Is that even possible? Seems like it should be. Maybe I should be fiddling with archives?
Thanks for the help Evan. You got me thinking for sure. It’s not like ‘URL/category’ or ‘URL/page’ will work without a category or page being named, so maybe that’s why I’m getting nothing out of ‘URL/custom_tax’.
Any other ideas? I can stick with my hierarchical hack in the meantime and will post an answer when I come up with one.
Forum: Fixing WordPress
In reply to: User Menu link to a Custom TaxonomyI might have tried that if I understand you correctly and I got an error.
on the live site it’s “URL/custom_taxonomy/all-beer”
On my local clone of the site I changed the taxonomy to non-hierarchical, refreshed the permalinks, and then tried simply “URL/custom_taxonomy” it gave me the 404 page.
Forum: Plugins
In reply to: [Contact Form 7] generate large number of tags?OK, solved this on my own.
For anyone else with a few hundred tags needed on a form who didn’t already know the following:
You don’t actually have to use the “generate tag” button to generate a tag. If you had a hundred products that were variations on the same thing you can generate one tag and title it “item-1”
It’ll give you:
[number-item-1]
for the form and:
[item-1]
for the email.
Then you just enter:
[number-item-2],[number-item-3], etc.
in the form and:
[item-2],[item-3]. etc.
in the email. As many as you want. Worked like a charm for me.