Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other WordPress hide categories from logged out users

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #44612
    Justin_G
    Member

    Hi all.

    My client has a blog area in their site. They have two main categories, ‘dealer blogs’ and ‘public blogs’. Ideally, we want both logged in and logged out users to be able to go to the same page and see rather a) just public blogs, or b) both public, and ‘dealer only’ blogs.

    I have installed the plugin ‘user specific content’ and this seems to do what we need it to for the most part, however the plugin does NOT hide the blog completely, just shows a message saying ‘you must be logged in to view this content’. Also, the featured image still shows regardless of being logged in/out.

    the link: [http://www.sunspacemodular.com/blog/](http://www.sunspacemodular.com/blog/http://www.sunspacemodular.com/blog/”)

    If we could hide the ‘dealer’ category entirely when not logged in this would save all the hassle.

    Please keep in mind that we are using a purchased theme, and would like to avoid directly changing their code. We do have access to our own custom JS, CSS, and functions files.

    Thank you very much, and I apologize for the long post.
    Justin

    #134362
    TheDoc
    Member

    You shouldn’t really need a plugin for this. You just need to use this:

    Resource: http://codex.wordpress.org/Function_Reference/is_user_logged_in

    Inside your `is_user_logged_in` conditional, you can run the loop for your dealer blogs. Just have to make sure that you also use it on the actual single pages so that logged out people can’t see the single posts, either.

    So you’d do something like:

    echo ‘Sorry, you need to be logged in to view this post. Log in.‘;
    } ?>

    #134367
    Justin_G
    Member

    @TheDoc, This is exactly what I would do in a normal scenario, but I don’t want to edit the themes files. I am still relatively new with custom functions, is there a way to hook into the blog page with a custom function to accomplish this?

    I just don’t want my client to run an update, and my changes be overwritten.

    Thanks
    Justin

    #134368
    TheDoc
    Member

    I’m not sure I understand, what theme are you using that you think is going to overwritten?

    #134378
    Justin_G
    Member

    The theme I am using is [http://theme-fusion.com/avada/](http://theme-fusion.com/avada/http://theme-fusion.com/avada/”)

    My understanding of theme’s is that if you edit the core theme files and there is an update, the update will override my changed UNLESS it is in the custom_css/js/function files.

    Thanks

    #134379
    chrisburton
    Participant

    @TheDoc isn’t talking about changing the core files but rather the theme.

    Core files will be overwritten but theme files will not.

    Therefore, anything inside the themes folder will not be overwritten. Hope that clears things up for you.

    #134380
    TheDoc
    Member

    Although, you *can* get theme updates as well. I think what people normally do here is create a child theme that has all of their changes in it, but I’ve never done that before.

    #134439
    Justin_G
    Member

    Beautiful, thanks for the clarification everybody.

    I must look into child themes!

    @scottnix
    , pre_get_posts looks like the perfect solution, thanks!

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘Other’ is closed to new topics and replies.