WordPress.org

Ready to get started?Download WordPress

Forums

Contextual Related Posts
[resolved] Custom post types question (10 posts)

  1. funky_buddah
    Member
    Posted 1 year ago #

    Hello all, I have the following situation:

    I'm using CRP on the default wordpress posts (single.php) and also on a custom post type (single-downloads.php).
    I'd like to customize where the related posts container is displayed in single-downloads.php.
    The content structure of the post types is different and the default display which is works ok in sigle.php is badly positioned in single-downloads.php.

    I tried to disable the automatic display of crp and manually insert the echo_ald_crp function and customize the positioning using css but this also messes up the positioning in some posts. The only good option for me is the default display (after the content).

    I think the best solution for now will be to display the related content in a sidebar widget in single-downloads.php. But now comes the problem: if I enable that, I come up with 2 related posts containers, one in the sidebar and one in the post's content. How can I disable the one in the content?

    http://wordpress.org/extend/plugins/contextual-related-posts/

  2. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    You could try this:

    If you know the post IDs for the single-downloads file, you can enter these in the "exclude display on following posts" field in the settings page.

    Then, like you did earlier, edit the single-downloads.php file to manually add the code to display the related posts.

  3. funky_buddah
    Member
    Posted 1 year ago #

    Thanks for the reply, Ajay.

    But I need an automatic solution, it's a pretty big site.

  4. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Unfortunately, there isn't an automated solution for custom post level. I've got better custom post support in the pipeline, but unfortunately it's not a quick fix.

    Is there a reason you don't want to use only the widget for both single and single-downloads?

  5. funky_buddah
    Member
    Posted 1 year ago #

    I cannot use the widget on both post types because of different content structure and alignment issues.

    Or, can I use the widget on both post types and customize it with css? I mean can I assign different css classes and divs for the widget in order to have different layouts for crp in single and downloads?

  6. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    You can use the widget and style it with CSS.

    You'll ideally need to put the different pieces of CSS in the single.php and single-downloads.php files.

    You could also try using Widget Logic plugin to control the widgets. I haven't used this personally yet.

  7. funky_buddah
    Member
    Posted 1 year ago #

    Thanks man, I will try to do that.

    Any ideas on how can I assign different CSS styles to single and single-downloads? I'm not much of a CSS guru.

  8. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Most likely, you'll need to edit your header.php and use a conditional tag:

    https://codex.wordpress.org/Conditional_Tags#A_Post_Type

    So something like:

    if ( is_singular ('downloads') ) {
      ADD CSS Code for Single-downloads.php
    } else {
      ADD CSS Code for Single.php
    }
  9. funky_buddah
    Member
    Posted 1 year ago #

    Thanks again. I think you're the most helpful plugin author I had to deal until now :)

  10. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    You're welcome :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.