- This topic has 45 replies, 3 voices, and was last updated 5 years, 6 months ago by Tom.
-
AuthorPosts
-
September 20, 2018 at 10:46 am #682378TomLead DeveloperLead Developer
This has been pretty stumped, it should be working. I’m on the road until tomorrow so I don’t have a localhost to test with, unfortunately.
One more thing to try before I get back into the office tomorrow to figure out exactly why it’s not working:
add_action( 'generate_after_content', function() { if ( is_singular( 'your-post-type-name' ) ) { previous_post_link(); next_post_link(); } } );
Let me know if that displays anything at all.
September 20, 2018 at 1:32 pm #682472EvaAgain…. nothing.
Don’t worry about the time, I am not in a hurry.
I’d rather use WP Show Posts (I also have the PRO version) if I wouldn’t need a filterable portfolio with CPT’s…
Thanks for you patience and support!September 20, 2018 at 10:58 pm #682707TomLead DeveloperLead DeveloperNo problem – I’ll dig into this ASAP and will let you know what I find out π
September 24, 2018 at 8:16 am #685127EvaHi Tom, thank you! It would be great if the problem can be solved. Even better if I could use WP Show PostsPRO and have a filterable portfolio… That would be the best π
I know it’s not a feature yet, but maybe it can be done another way?
Thanks,
EvaSeptember 24, 2018 at 4:24 pm #685491TomLead DeveloperLead DeveloperSo I just built a custom post type and named it
project
.I then added this function:
add_action( 'generate_after_content', function() { if ( is_singular( 'project' ) ) { previous_post_link(); next_post_link(); } } );
And it’s showing the links for me. They need to be styled with CSS, but they’re there.
September 25, 2018 at 5:56 am #685813EvaYessss! Great, it works!! You’re a genius π
Now, to show categories and tags, I add?Thanks!!!
September 25, 2018 at 8:15 pm #686400TomLead DeveloperLead DeveloperAwesome π
Are those taxonomies registered in your custom post type? Or do you have custom taxonomies?
September 26, 2018 at 5:44 am #686702EvaI use custom taxonomies: Projectsoorten and Trefwoorden
Thanks!
September 26, 2018 at 10:33 am #687043TomLead DeveloperLead DeveloperSo you could try something like this:
add_action( 'generate_after_content', function() { if ( is_singular( 'project' ) ) { previous_post_link(); next_post_link(); $projectsoorten = get_the_term_list( get_the_ID(), 'projectsoorten' ); $trefwoorden = get_the_term_list( get_the_ID(), 'trefwoorden' ); if ( $projectsoorten ) { echo $projectsoorten; } if ( $trefwoorden ) { echo $trefwoorden; } } } );
Obviously, it would need to be styled with CSS.
September 26, 2018 at 1:31 pm #687157EvaUnfortunately I got an error… I send you the code for the Projectsoort taxonomy, because I think what I send you was not correct (sorry, ones again π
function your_prefix_register_taxonomy() {
$args = array (
‘label’ => esc_html__( ‘Projectsoorten’, ‘text-domain’ ),
‘labels’ => array(
‘menu_name’ => esc_html__( ‘Projectsoorten’, ‘text-domain’ ),
‘all_items’ => esc_html__( ‘All Projectsoorten’, ‘text-domain’ ),
‘edit_item’ => esc_html__( ‘Edit Projectsoort’, ‘text-domain’ ),
‘view_item’ => esc_html__( ‘View Projectsoort’, ‘text-domain’ ),
‘update_item’ => esc_html__( ‘Update Projectsoort’, ‘text-domain’ ),
‘add_new_item’ => esc_html__( ‘Add new Projectsoort’, ‘text-domain’ ),
‘new_item_name’ => esc_html__( ‘New Projectsoort’, ‘text-domain’ ),
‘parent_item’ => esc_html__( ‘Parent Projectsoort’, ‘text-domain’ ),
‘parent_item_colon’ => esc_html__( ‘Parent Projectsoort:’, ‘text-domain’ ),
‘search_items’ => esc_html__( ‘Search Projectsoorten’, ‘text-domain’ ),
‘popular_items’ => esc_html__( ‘Popular Projectsoorten’, ‘text-domain’ ),
‘separate_items_with_commas’ => esc_html__( ‘Separate Projectsoorten with commas’, ‘text-domain’ ),
‘add_or_remove_items’ => esc_html__( ‘Add or remove Projectsoorten’, ‘text-domain’ ),
‘choose_from_most_used’ => esc_html__( ‘Choose most used Projectsoorten’, ‘text-domain’ ),
‘not_found’ => esc_html__( ‘No Projectsoorten found’, ‘text-domain’ ),
‘name’ => esc_html__( ‘Projectsoorten’, ‘text-domain’ ),
‘singular_name’ => esc_html__( ‘Projectsoort’, ‘text-domain’ ),
),
‘public’ => true,
‘show_ui’ => true,
‘show_in_menu’ => true,
‘show_in_nav_menus’ => true,
‘show_tagcloud’ => true,
‘show_in_quick_edit’ => true,
‘show_admin_column’ => false,
‘show_in_rest’ => false,
‘hierarchical’ => false,
‘query_var’ => true,
‘sort’ => false,
‘rewrite_no_front’ => false,
‘rewrite_hierarchical’ => false,
‘rewrite’ => true,
);register_taxonomy( ‘projectsoort’, array( ‘project’ ), $args );
}
add_action( ‘init’, ‘your_prefix_register_taxonomy’, 0 );September 26, 2018 at 6:51 pm #687290TomLead DeveloperLead DeveloperWhat was the error?
September 28, 2018 at 1:14 pm #688904EvaSorry, this is the error:
Catchable fatal error: Object of class WP_Error could not be converted to string in /home/alfabetp/test.alfabetprodukties.nl/wp-content/themes/generatepress_child/functions.php on line 22
Hope this is of any use…
Thanks again!!September 28, 2018 at 7:42 pm #689061TomLead DeveloperLead DeveloperAre
projectsoorten
andtrefwoorden
the correct IDs of the taxonomies? I only guessed based on their names.September 29, 2018 at 6:14 am #689283EvaI think I the ID’s are projectsoort and Trefwoord, because now I don’t get an error anymore. It all looks quite strange though, and even more when I click to open a similar project…
But I am happy it’s almost resolved now!! Thank you for spending so much time!September 29, 2018 at 10:36 am #689485TomLead DeveloperLead DeveloperThey likely need to be styled with CSS to look good. I’m not seeing any of the tags listed on your project pages though?
-
AuthorPosts
- You must be logged in to reply to this topic.