Hi MDVG
The plugin should detect if Pages have taxonomies (registered). Can you explain some more of what it is you want to do
Thread Starter
MDVG
(@mdvg)
Hey, thanks for your swift reply!
See screenshot: https://imgur.com/a/sMAF3MJ
I am not able to ‘select’ pages.
Do pages have any taxonomies registered to them?
If not you can try it with this in your (child) theme’s functions.php file
function rpbt_add_taxonomies_to_pages() {
register_taxonomy_for_object_type( 'post_tag', 'page' );
register_taxonomy_for_object_type( 'category', 'page' );
}
add_action( 'init', 'rpbt_add_taxonomies_to_pages' );
btw:
consider creating a child theme instead of editing your theme directly – if you upgrade the theme all your modifications will be lost. Or create a plugin with the code above.
Thread Starter
MDVG
(@mdvg)
Thanks for your help so far!
-When adding your code to functions.php, the site crashes.
-When creating a custom plugin with your code, nothing happens.
-However, I searched a bit and found out that this piece of code is acutally adding ‘pages’ to your widget. Unfortunately, on the front end, it’s not displaying results 🙁
add_action( 'init', 'pages_tax' );
function pages_tax() {
register_taxonomy(
'things',
'page',
array(
'label' => __( 'Things' ),
'rewrite' => array( 'slug' => 'things' ),
'hierarchical' => true,
)
);
}
Maybe I am thinking far to easy, but why not simply adding a piece of code to the current plugin and add ‘pages’?
Pages, by default, don’t have taxonomies. You’ll have to add them yourself. The plugin will display the Page post type (in the widget) if it has taxonomies. This is because most users don’t add taxonomies to pages.
Did you add terms from the things
taxonomy to pages, so the plugin can find related posts (pages) with terms in common?
Thread Starter
MDVG
(@mdvg)
Ah, right! I understand!
This piece of code create something similar as ‘categories’ with posts, but in this case for pages.
Once I added taxonomies to the specific pages, the ‘related pages’ are now showing up in the sidebar/widget.
See result: https://bit.ly/2wPaXLx
Many thanks for your help!
Thread Starter
MDVG
(@mdvg)
Hey Keesie,
Just a follow up. I decided to make my solution public via a custom plugin via: https://wordpress.org/plugins/taxonomy-pages/
Of course, all credits to you!
Maybe you can refer people to this plugin if they have the same question as I had.