Forum Replies Created
-
AuthorPosts
-
Knüt
ParticipantHello Francesco!
You need to add both of these PHP snippets to your site (via functions.php or using a code snippet plugin such as WPCodeBox): https://kellenmace.com/remove-custom-post-type-slug-from-permalinks/
Then, change where it says "race" for the slug of your CPT.
After that, go to Settings > Permalinks and re-save being /%postname%/ your structure.
And it should work! 🙂 I have tested just now in a website I am working on.
Knüt
ParticipantJust for future reference, what have worked best for me is following these steps:
https://kellenmace.com/remove-custom-post-type-slug-from-permalinks/Knüt
ParticipantHi!
I rewrite all the code using
echo, notprintf, and now it works fine!Thanks for your help!
Knüt
ParticipantHi,
That's great!
Do you know how I can print
$mes_butlletiand$any_butlletiinto the HTML below?I would like to have those term data where it says
<p>HERE I NEED TO PRINT THE mes_butlleti AND any_butlleti DATA<p><?php $terms = get_terms( array( 'taxonomy' => 'butlleti', // set your taxonomy here 'orderby' => 'none', // default: 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => true, // default: true 'number' => 1, )); if ( empty( $terms ) || is_wp_error( $terms ) ) { return; } echo '<div class="butlletins__list-container">'; foreach( $terms as $term ) { $mes_butlleti= rwmb_meta( 'mes_butlleti', ['object_type' => 'term'], $term->term_id ); $any_butlleti= rwmb_meta( 'any_butlleti', ['object_type' => 'term'], $term->term_id ); echo $mes_butlleti; echo $any_butlleti; printf( '<a href="%s"> <div class="butlletins__list"> <p class="p-big">BUTLLETÍ N. <strong>%s</strong></p> <div class="butlletins__list-line"></div> <p>HERE I NEED TO PRINT THE mes_butlleti AND any_butlleti DATA<p> <span class="butlletins__list-new">NOU</span> </div> </a>', esc_url( get_term_link( $term ) ), esc_attr( $term->name ), $term->count ); } echo '</div>'; ?>Thanks!!!
Knüt
ParticipantHi Long Nguyen,
Thanks for your help!
I've been reading your documentation, but I can't figure it out how to make it work with the code I already have to show both the Terms and a Custom Field of that term.
Could you please help me figure it out?
Thank you!
November 16, 2021 at 3:19 PM in reply to: ✅How to remove the slug from the permalink of a CPT #31979Knüt
ParticipantThank you! 🙂
Knüt
ParticipantHi,
Ok, that's great! The documentation was quite confusing at first.
Thank you Long Nguyen!
-
AuthorPosts