• Hi all,
    I appreciate the ability to dynamically reconstruct content but the effect is sometimes confusing…

    In my CHILD THEME I can control category posts order BUT a “single” post is don’t display category_archive_meta and page navigation…

    The category template uses page navigation and can cycle through all posts in a category BUT if I click a link to a post in another category it seems to dynamically generate a “single” post that is isolated from the category cycle and page navigation is gone or defunct.

    How can I set ONE template to be used for ALL posts – such as category.php instead of using multiple ones?

Viewing 15 replies - 1 through 15 (of 21 total)
  • In theory, you can just use a single index.php template file. Within the template hierarchy, that is the default template for everything. See Theme_Development.

    Thread Starter insurgenesis

    (@insurgenesis)

    Hi Esmi, thanks for prompt response!

    Wouldn’t it weigh to heavily if everything is composed with index.php?

    Ideally I’ll keep index.php and category.php but I don’t understand why single posts (presumably using single.php and content-single.php) produce this “isolated” result.

    So I fantasised that killing the “single” templates would result in posts acquiring the qualities of catagory.php.

    Will that in fact be the case or only fantasy?

    Wouldn’t it weigh to heavily if everything is composed with index.php?

    Not sure what you mean by “weigh to heavily”.

    One of the older default WordPress themes (Classic) had very few theme template files. Themes still exist with only 1 or 2 template files. But these are standalone themes – not child themes. A child inherits its parent’s template files automatically. So you can’t create a single template child theme and expect the parent’s files to be ignored.

    I fantasised that killing the “single” templates would result in posts acquiring the qualities of catagory.php

    Putting aside the fact that you cannot “kill” a parent template via the child, in the situation you describe, a standalone theme without a single.php file would fallback to using index.php.

    Thread Starter insurgenesis

    (@insurgenesis)

    OK being a child theme of Twenty Eleven, and putting aside the possibility of killing any of its templates, I should still be able to modify the single.php and content-single.php of the child theme to be identical to its the category.php. True?

    You see I need single posts to look like they belong in categories (which they do). Otherwise, if single templates have a different way of cycling through successive posts within their category using default navigation, and jumping to adjacent categories when you reach “the end”, as it were, it’s very confusing for a user.

    Honestly, do you know what I mean? Forgive me for using metaphorical language – I don’t know any better.

    I should still be able to modify the single.php and content-single.php of the child theme to be identical to its the category.php. True?

    Yes – that should be possible if you create new single.php and content-single.php template files.

    I need single posts to look like they belong in categories

    What is it that you are trying to do? Format posts visually to establish a conceptual link to a specific category? Like have all posts from Cat A with a blue background and post for Cat B having a red background?

    Thread Starter insurgenesis

    (@insurgenesis)

    Like have all posts from Cat A with a blue background and post for Cat B having a red background?

    No, precisely Not like that – it has to have a consistent presentational style.

    I need to include the same navigation method that category.php employs to cycle through posts in a category for single posts, so that single posts never appear outside their category cycles as disparate content pieces – if you know what I mean – to avoid this (established in 1st post):

    The category template uses page navigation and can cycle through all posts in a category BUT if I click a link to a post in another category it seems to dynamically generate a “single” post that is isolated from the category cycle and page navigation is gone or defunct.

    BTW I sincerely hope you know what I mean and that this is a standardised design feature and not a glitch of sorts because if you do not know it’s unlikely that others will – considering the semantic difficulty of describing my problem…

    Will it help if I drop the code into paste bin?

    I think I understand what you mean. Assuming I am correct in my understanding, have you had a look at:

    https://codex.www.ads-software.com/Function_Reference/next_post_link
    https://codex.www.ads-software.com/Function_Reference/previous_post_link

    Specifically the in_same_cat argument. Does that help?

    Thread Starter insurgenesis

    (@insurgenesis)

    Thanks for that – there are some nice ones but they don’t fit the criteria.
    I need to limit single posts to their own category without the possibility of jumping to adjacent categories – something like “Text As Link, With Post Title, Within Same Category And Limited To That Category”. I also don’t see this working: “Within Same Category, Excluding One” because I’ll want to exclude “All Others”.
    Is there an “All” delimiter?

    Thread Starter insurgenesis

    (@insurgenesis)

    Anyway, for enhanced navigation I used a custom child theme function and invoked it in index.php and category.php by replacing
    <?php twentyeleven_content_nav( 'nav-below' ); ?> with
    <?php function_pagination(); ?> producing good results.

    Problem is that <?php twentyeleven_content_nav( 'nav-below' ); ?> does not appear in either single.php or content-single.php because it uses <nav id="nav-single"> instead.
    I can’t simply replace this as with the others (so it’s not going to be a pasting exercise) and I will have to invoke the navigation function in a way I’m not familiar with.

    Q: What is the correct way to invoke that function from within single.php and content-single then?

    I’m not sure why you can’t just call <?php function_pagination(); ?> in place of:

    <span class="nav-previous"><?php previous_post_link( '%link', __( '<span class="meta-nav">&larr;</span> Previous', 'twentyeleven' ) ); ?></span>
    <span class="nav-next"><?php next_post_link( '%link', __( 'Next <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></span>

    Is this a styling issue? Or perhaps you need to create function_pagination_single() as an amended version of the custom function? Invoking a custom function is pretty straightforward. If it’s in your theme’s functions.php file, you can call it in any template file. The specifics might vary (for example, do you need to declare global $post; in the new function or pass it some other variable) but that’s about it.

    Thread Starter insurgenesis

    (@insurgenesis)

    Thanks again for checking back. Truthfully I don’t know what

    declare global $spot

    means or how to

    amend a version of the custom function

    though my intuition is to amend.

    All I know is it doesn’t work to simply replace the <spans>
    and calling (previously invoking) with function_pagination_single() from within the singles.

    If I can successfully call that function from within the template files which compose single posts, I will have consistent cross-site navigation.

    declare global $spot

    Sorry! Typo! That should have been global $post; (I swear my fingers are dyslexic). Sometimes required when you need access to a posts object within a function.

    What exactly is in function_pagination()? Why won’t it work in single.php? What happens?

    Thread Starter insurgenesis

    (@insurgenesis)

    Nothing happens.

    Here it is: https://pastebin.com/G1TNrTnv

    You’re not taking single Posts into account using (for example) the is_single() conditional. I think you need to code for them separately – possibly around if(1 != $pages) as $pages is always going to equal 1 on a single Post.

    Thread Starter insurgenesis

    (@insurgenesis)

    I’m not sure how to do that. If you happen to know but feel you don’t want to disclose, just do it anyway and send me your Amazon wishlist ??

    Do you mean “code separately” like two discrete functions – one for category and one for singles?

    But why does it not show up when I call it in single?

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Twenty Eleven – Set ALL posts to use one navigation template?’ is closed to new replies.