WordPress.org

Ready to get started?Download WordPress

Forums

making links to posts not open in single.php (11 posts)

  1. da_silva
    Member
    Posted 7 years ago #

    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?

  2. yosemite
    Member
    Posted 7 years ago #

    How would you like a single post to be displayed (differently then it is now)?

  3. da_silva
    Member
    Posted 7 years ago #

    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 :P

  4. da_silva
    Member
    Posted 7 years ago #

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

  5. moshu
    Member
    Posted 7 years ago #

    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.

  6. Kafkaesqui

    Posted 7 years ago #

    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:

    http://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?

  7. da_silva
    Member
    Posted 7 years ago #

    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?

  8. Kafkaesqui

    Posted 7 years ago #

    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.

  9. da_silva
    Member
    Posted 7 years ago #

    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

    http://codex.wordpress.org/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...

  10. da_silva
    Member
    Posted 7 years ago #

    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');
    ?

  11. tommy2toes
    Member
    Posted 7 years ago #

    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:

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

Topic Closed

This topic has been closed to new replies.

About this Topic