• i want only some posts to open in single.php and i don’t know how the links are got or what’s the mechanics of getting a link to a post open in single.php so i can avoid it.
    Can u tell me where to look or what to change cause i don’t knoe how and why permalinks open in single.php?

Viewing 10 replies - 1 through 10 (of 10 total)
  • How would you like a single post to be displayed (differently then it is now)?

    Thread Starter da_silva

    (@da_silva)

    i want it displayed the same as all the posts in a certain category are displayed, only that this time this alone will be displayed with the comments. I don’t know if you understand, imagine that you click a category that has 5 posts listed under each other. When you click on one title you get in the single post view, with no sidebar (depending on how single.php is constructed). I want to use index.php as target for single posts and not single.php.

    I don’t know if it’s possible without deleting the file , as i know that the hierarchy works like that. But some of the posts, that are large with large images would look better without sidebar so for those ones i want to display single posts in single.php.

    Hope you understand anything ??

    Thread Starter da_silva

    (@da_silva)

    sorry for insisting but no one has an explanation? ??

    Well, if you know how the hierarchy works… then you know as well it doesn’t work like that. Nobody has an answer or “explanation” because there isn’t any.

    Well, it doesn’t work like that *right now.* But say we provided a custom field entry, something like:

    key: template
    value: wide

    And then modified my plugin here:

    https://guff.szub.net/2005/07/21/post-templates-by-category/

    To set a template based on the ‘template’ custom field. Would that work for you?

    Thread Starter da_silva

    (@da_silva)

    I really don’t want to use plugins, i want to understand how it is done.
    Please make me understand how every permalink with the ?p=xx (xx-the post’s id) gets processed by single.php.
    As far as i can understand when one types ?var=… after index.php for example that means the irrespective variable is passed to the php page so it does whatever needed with it. In our case, how does index.php handle this variable?

    It might help to see WordPress as the Master of Templates. When an individual post is called, whether by ?p=XXX or ?name=the-post-title (the latter is used behind the scenes for custom permalinks which incorporate the ‘post slug’), then WordPress looks to see if a single.php template exists for the active theme. If it does, that template is called. If not, the theme’s index.php is used.

    That’s pretty much it. If you want to “avoid it” then you’re going to have to code around it, by plugin or some other method.

    Thread Starter da_silva

    (@da_silva)

    this is exactly what i’m trying to do, find some method to “avoid” wordpress to call single.php when showing posts in some categories and “force” index.php to do that while use single.php for other categories.

    Can you point where exactly does wordpress process this?
    I’ve seen on

    https://codex.www.ads-software.com/User:alphaoide/wp_powered_photoblog

    that trying to force “$wp_query->is_single = true;” in index.php would do the trick but i can’t seem able to do that.

    edit: i’ve started to read any function called from the index.php in wordpress up to index.php in my template and i’ve found some hints. So I guess template_loader.php does assign the single.php template if is_single() is true for any page…digging further…

    Thread Starter da_silva

    (@da_silva)

    hmmm, add_action('template_redirect', 'file')
    Could this be what i am looking for? If it is, where can i use it? Where can i write something like:

    if (in_category(9)and in_category(10))
    add_action('template_redirect', 'cat9_10');
    ?

    Well, if you know how the hierarchy works… then you know as well it doesn’t work like that. Nobody has an answer or “explanation” because there isn’t any.

    People like this need to get a life, seriously.

    Here is someone with a response with a little more ingenuity:

    https://lorelle.wordpress.com/2005/09/22/creating-multiple-single-posts-for-different-categories/

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘making links to posts not open in single.php’ is closed to new replies.