• Resolved MDVG

    (@mdvg)


    Hey Keesie,

    I am a long time user of your plugin for my other WordPress website and a big fan!

    With the theme I am working with now, I am using ‘pages’ as main content source.

    It’s possible in your plugin to relate ALL types of content, EXCEPT for pages.

    Are you willing to create an option to relate pages so I can use this plugin as well for my current website.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author keesiemeijer

    (@keesiemeijer)

    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.

    Plugin Author keesiemeijer

    (@keesiemeijer)

    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’?

    Plugin Author keesiemeijer

    (@keesiemeijer)

    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.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Not possible to relate pages’ is closed to new replies.