Point a custom php page template to use/inherit OneColumn-No SideBar format???

  • Anonymous

    #2780

    I have setup a child theme for graphene. In the child theme, I have created a links.php file that basically lists all of the defined links by link category. So in WP Dashboard, I create a page called Links, then I set the page attributes TEMPLATE = link.php

    I have 2 questions:

    1) How can I have the links.php file “inherit” the template format provided in “OneColumn-No side bar” template?

    I have tried adding a loop-single.php file (basically just copied from the parent) and then added a line in the links.php “<?php get_template_part(‘loop’,’single’);?>” What it does is remove all the content from my other pages that use “OneColumn-No sidebar” template. Here is all of the code:

    *************

    <?php
    /*
    Template Name: Links Page
    */
    ?>

    <?php get_header(); ?>

    <div id="posts" class="page">

    <?php while(have_posts()) : the_post(); ?>

    <div class="post" id="post-<?php the_ID();?>">

    <h2><a>" title="<?php the_title(); ?>"><?php the_title();?></a></h2>

    <div class="entry">

    <?php wp_list_bookmarks('category_before=&category_after=&title_before=<h3>&title_after=</h3>&show_images=0;&show_images=1;&show_description=1'); ?>

    </div>

    </div>

    <?php endwhile; ?>

    <?php get_template_part('loop','single');?>

    </div>

    <?php get_footer(); ?>

    </div>

    </body>
    </html>

    ***************

    #2) In this same code, I would like to have a blank line inserted between the link categories and postings. Is that possible?

    Thanks in advance for any assistance! I am new to WordPress! –Mic

    Mod

    Kenneth John Odle

    #21877

    I am new to WordPress!

    And yet still completely fearless.

    My question is, what is this page of links actually linking to? Do you mean that you simply want a page that lists all your posts by category? If so, there is a much easier way to do that. If not, let me know what these links link to.

    Mod

    Kenneth John Odle

    #21878

    You might also want to include a link to your site, if that will help.

    If you are trying to create a list of posts by category, then use Kalin’s List Post plugin. You can create a separate shortcode for each category, and then just add that to a regular page.

    The tutorial is here:

    http://blog.kjodle.net/2011/10/30/kalins-post-list-a-brief-tutorial/

    An example that I actually use on my blog is here:

    http://blog.kjodle.net/projects/project-wideawake/

    Anonymous

    #21879

    Hi – Thanks for the fast reply! Actually my site is still in a temporary url bcz I already have a live website on yahoo, but I will be transferring that domain to this website when it is ready to publish. I am actually not trying to categorize posts right now, tho that is next on my list! So thanks for the info on the Plugin!

    I am actually trying to create a fairly static page of external links that I recommend to my clients. My business is dog training, so I have a list of links that I want to share of other dog related businesses and competition sites, etc. I have a jpg screen shot (compressed) that I could send you. I don’t know how to insert it in this reply tho. A rough draft would be something like this:

    *******

    LINKS (page title)

    Friends (section title based on link category name)

    *Friend IMG 1 – description of friend business (from link description field)

    *Friend IMG 2 – description of friend business

    etc….

    Agility (section title based on link category name)

    *Site url 1 – Description of site (from link description field)

    *Site url 2 – Description of site

    etc…

    ******

    Does this help? If not, let me know where I can send you a screen shot or how to add to reply post

    These are all external links, not posts. I want to apply/associate the 1 col-no sidebar template with the links.php that I have created. Unless there is a better way to do it. I am all ears! Just started working with WordPress 4 days ago… So I am definitely a newbie!

    THANK YOU! 🙂

    Jon Lynch

    #21880

    I think you are very close to achieving what you want to do.

    0) make sure you have not made any changes to loop.php and rename your loop-single.php to loop-links.php

    1) copy template-onecolumn.php from graphene to you child theme.

    2) rename this to template-links.php or similar & change the title in the header

    3) change get_template_part(... to get_template_part('loop','links');

    4) select this template in a page and you should be good to go!

    I have done similar at http://www.wmrt.org.uk/advice/accident-black-spots/scafell-broad-stand/ and http://www.wmrt.org.uk/gallery/

    Hope this helps

    Jon

    Anonymous

    #21881

    Jon – Thank you for your steps above, but I must still be missing something… It still displays the sidebar. I verified that the page attribute is set to new “Links OneColumn” template which is what I renamed.

    0) “Make sure no changes to loop.php” I verified, this, but I didn’t have loop.php in my child theme directory. Copied to my child them (no name change), still did not work. Then tried to rename it loop-link.php and did not work.

    “Rename loop-single.php to loop-links.php” – Did this. But my loop-single was originally a copy of “page.php” I tried changing get_template (‘loop’,…) to ‘link’ and to ‘single’ to see if that made any difference. It did not.

    1-2) Copied template-onecolumn.php to template-links.php and updated template name = “Links One Column”

    3) changed get_template _part to (‘loop’, ‘links’); in “template-links.php”

    4) created new page called Link Friends, selected page attribute = “Links one column)… When I refreshed page, the side bar is still there.

    Then I thought maybe I read step 4 incorrectly and perhaps I should change get_template_part(‘loop’, ‘links’ in loop-links.php and links.php. That didn’t work either, so then I basically went through all of the combinations between the 3 files (loop-links.php, template-links.php, and links.php trying to find the combinations of of the get-template_parts(‘loop’,’page, links, single’ trying to find the correct combination. None of them worked…

    Am I missing a statement in the child style.css file? Or do I need a child function.php file update? Not sure… But on the “Links” edit page, if I select page attributes = “One column, no sidebar” — The page format is correct, but the external link data does not display… When I change to “Link One Column” depending on the get_template_parts combination, the links will display, but the page format is never the same as “one column, no sidebar”

    Any suggestions? Thanks in advance! — Mic

    Mod

    Kenneth John Odle

    #21882

    Still, it seems easier just to use a heading (whatever level you would like) and enter the links yourself. Not difficult, especially if you aren’t going to change them.

    Anonymous

    #21883

    Ken – I decided to go ahead and move forward with your suggestion to just insert all of the data in the Edit Page Visual section of a new Links2 page. I thought it would be easy right?!!!! All the images, links and “paragraph” content is showing up. Anything I enter and format with a “heading” format will not publish. Its on the Visual tab, it seems to be on the html tab. I can preview it and it looks like it is there. But when I publish the page and view… Nothing… Nada… All text assigned heading format is blank

    Any ideas? Saw something on google that it might be a stackoverflow??? My eyes are crossing on that… Have no idea what that means! 🙂 — Mic

    Anonymous

    #21884

    Disregard. Figured it out… I would still like to get the other way working, but this lets me move on to the next thing! Thank you!

    Jon Lynch

    #21885

    Hi again, sorry the first method didn’t work for you. Whilst thinking about what was going on with the CSS I came up with a much simpler way of doing this: filtering the_content when on your links page:

    <?php
    // add the filter
    add_filter ('the_content', 'jl_add_links');

    function jl_add_links ($content) {
    if (!(is_page('list-links'))) return $content;
    $content .= wp_list_bookmarks('category_before=&category_after=&title_before=<h3>&title_after=</h3>&show_images=0;&show_images=1;&show_description=1&echo=0');
    return $content;
    }
    ?>

    This can go in your functions.php then all you have to do is create a page with the slug list-links and set the template to one-column, no other changes required.

    Note: this time I tested this before writing!

    In answer to your second original question a line break could be added by putting <br /> after the </h3> in the title_after attribute.

Viewing 10 posts - 1 through 10 (of 11 total)

You must be logged in to reply to this topic.

Do NOT follow this link or you will be banned from the site!