Forum Replies Created

Viewing 15 replies - 1 through 15 (of 24 total)
  • Thread Starter thisismyalias

    (@thisismyalias)

    You are right about the space issue. I’m not sure what was happening, but I redid the code and the spacing issue is gone. Now I can use the for loop, and I used your custom field idea, and it works. Thank you so much for your help. I learned a lot with this exercise.

    Thread Starter thisismyalias

    (@thisismyalias)

    Thank you. That’s a good suggestion. I get weird spacing with the loop, and I’m sure I could fix it with some CSS modifications, but being a novice at all this, I don’t want to go down that path at the moment. Therefore, I’m going to figure out how to assign each child page data from the array statically.

    Thread Starter thisismyalias

    (@thisismyalias)

    I figured it out, using your help; however, after getting it I realized that I couldn’t loop through the child pages because I needed to add verbiage after each link. My solution is to hard code the output, but fill in the links from the get_pages array.

    My new problem is that I can’t figure out how to call a particular result of the array. For example, the code gets the child page of the current parent (there will only ever be 2 child pages). I need to call the URL of the first child page, but I can’t figure out how to access the first dimension of the array. Every single example I found loops through arrays.

    <?php
                $mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_title', 'sort_order' => 'asc' ) );
    
                ?>
                <section class="span4 articles-list" style="margin-left:0;">
                    <ul class="articles">
                        <li class="article-entry standard"><h4><a href="<?php echo ; ?>"><?php echo ; ?></a></h4>
                        <span class="article-meta">If you are ..., start here.</span>
                        </li>
                        <li class="article-entry standard"><h4><a href="<?php echo ; ?>"><?php echo ; ?></a></h4>
                        <span class="article-meta">If you are ..., start here.</span>
                        </li>
                    </ul>
                </section>
                <?php
    
            ?>
    Thread Starter thisismyalias

    (@thisismyalias)

    I’m going to re-read that another 10 times, and maybe it’ll start to make sense. 🙂 Thank you.

    Thread Starter thisismyalias

    (@thisismyalias)

    Thank you. Not all the pages are child pages (2 out of the 3 are), and the child pages are not named the same under each parent. I will definitely have to loop.

    I don’t see any nice & tidy way though. It’ll be more like if A = B then the links will be 1, 2, and 3. If A = C then the links will be 4, 5, and 6, etc.

    I’ll look further into get_pages and child_of though.

    Thread Starter thisismyalias

    (@thisismyalias)

    Well it’s very basic. The departments are just using a custom page template, and the page’s name is the department and thus the qualifier for the loop. The support page is a child of the department page. That’s really it.

    Thread Starter thisismyalias

    (@thisismyalias)

    I’m surprised that this isn’t possible without a plugin. I try to avoid plugin bloat, so I guess I may have to resort to a picture. Yuck.

    Thread Starter thisismyalias

    (@thisismyalias)

    The solution is that I need to use wp_reset_query(); between the last } and ?>.

    Thread Starter thisismyalias

    (@thisismyalias)

    Perfect! Thank you very much!

    Thread Starter thisismyalias

    (@thisismyalias)

    I see no way to edit my prior post. If I could I would delete all that code and just paste this portion:

    <section class="span4 articles-list" style="margin-left:0;">
    <!-- Best Practices  ID = 20-->
        <?php query_posts( array( 'category__and' => array($dept_id,20),
        'posts_per_page' => 5,
        'show_count' => 1 ) );
        $total_posts =$wp_query->found_posts;
        $myposts = $wp_query->post_count; 
    
        if ($myposts > 0) { ?>
            <h3><a href="/portal/?page_id=31?department_id=<?php echo $dept_id; ?>&department_name=<?php echo $deptname; ?>">Best Practices (<?php echo $total_posts; ?>)</a></h3>
            <?php while (have_posts()) : the_post(); ?>
            <ul class="articles">
       	        <li class="article-entry standard"><h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
                <span class="article-meta"><?php the_modified_date('F j, Y'); ?> in  <?php the_category(', ') ?> </span>
                <span class="like-count"><?php echo get_total_likes($post->ID); ?></span>
                </li>
            </ul>
    	<?php endwhile;
    	} ?>
    </section>

    After deleting out that portion of code the plugin works on the custom template. So it must be a query. Someone pointed me in the direction of <?php wp_reset_postdata(); ?> but adding it to the end of the template didn’t solve the problem. I’m still trying…

    Thread Starter thisismyalias

    (@thisismyalias)

    The custom template must be using custom database queries. I read the article on wp_reset_postdata() but I didn’t learn yet where it goes.

    That article made me think of trying something. I deleted out the part of the custom template with the new code (that I didn’t write) and the plugin worked as expected. So it does have something to do with the queries.

    The section is:

    <section class="span4 articles-list" style="margin-left:0;">
    <!-- Best Practices  ID = 20-->
        <?php query_posts( array( 'category__and' => array($dept_id,20),
        'posts_per_page' => 5,
        'show_count' => 1 ) );
        $total_posts =$wp_query->found_posts;
        $myposts = $wp_query->post_count; 
    
        if ($myposts > 0) { ?>
            <h3><a href="/portal/?page_id=31?department_id=<?php echo $dept_id; ?>&department_name=<?php echo $deptname; ?>">Best Practices (<?php echo $total_posts; ?>)</a></h3>
            <?php while (have_posts()) : the_post(); ?>
            <ul class="articles">
       	        <li class="article-entry standard"><h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
                <span class="article-meta"><?php the_modified_date('F j, Y'); ?> in  <?php the_category(', ') ?> </span>
                <span class="like-count"><?php echo get_total_likes($post->ID); ?></span>
                </li>
            </ul>
    	<?php endwhile;
    	} ?>
    </section>

    Thank you for the direction, I’m a little closer now.

    Thread Starter thisismyalias

    (@thisismyalias)

    It’s an intranet site. I will paste the code of the custom template though, since it’s this template that isn’t working (I can make a custom template by copying an existing one and just renaming it, and it works).

    <?php /*
    *   Template Name: Department Template
    Created 11/2014
    */
    get_header(); ?>
    
    <!-- Start of Page Container -->
    <div class="page-container">
        <div class="container">
            <div class="row">
    
                <!-- start of page content -->
                <div class="span8 page-content">
                <div class="row separator">
    
                    <?php
    
                    if ( have_posts() ) :
                        while ( have_posts() ) :
                            the_post();
                            ?>
                            <article id="post-<?php the_ID(); ?>" <?php post_class("clearfix"); ?>>
                                <h1 class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                                <hr>
                                <?php
                                if ( has_post_thumbnail() )
                                {
                                    the_post_thumbnail('std-thumbnail');
                                }
    
                                the_content();
    
                                // WordPress Link Pages
                                wp_link_pages(array('before' => '<div class="pages-nav clearfix">', 'after' => '</div>', 'next_or_number' => 'next'));
                                ?>
                            </article>
                            <?php
                        endwhile;
    
                    endif;
    
                    ?>
                    <?php
    				// get the department name's id# (passed through as page name parameter) so as to be able to indclude it in query array
    				$deptname = wp_title('', false);
    				$deptname=trim(strtolower($deptname));
    				$dept_id = get_cat_ID($deptname);
    				?>
    
    <section class="span4 articles-list" style="margin-left:0;">
    <!-- Best Practices  ID = 20-->
        <?php query_posts( array( 'category__and' => array($dept_id,20),
        'posts_per_page' => 5,
        'show_count' => 1 ) );
        $total_posts =$wp_query->found_posts;
        $myposts = $wp_query->post_count; 
    
        if ($myposts > 0) { ?>
            <h3><a href="/portal/?page_id=31?department_id=<?php echo $dept_id; ?>&department_name=<?php echo $deptname; ?>">Best Practices (<?php echo $total_posts; ?>)</a></h3>
            <?php while (have_posts()) : the_post(); ?>
            <ul class="articles">
       	        <li class="article-entry standard"><h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
                <span class="article-meta"><?php the_modified_date('F j, Y'); ?> in  <?php the_category(', ') ?> </span>
                <span class="like-count"><?php echo get_total_likes($post->ID); ?></span>
                </li>
            </ul>
    	<?php endwhile;
    	} ?>
    </section>
    
    <section class="span4 articles-list">
    <!-- Policies  ID = 21-->
        <?php query_posts( array( 'category__and' => array($dept_id,21),
        'posts_per_page' => 5,
        'show_count' => 1 ) );
        $total_posts =$wp_query->found_posts;
        $myposts = $wp_query->post_count; 
    
        if ($myposts > 0) { ?>
            <h3><a href="/portal/?page_id=33?department_id=<?php echo $dept_id; ?>&department_name=<?php echo $deptname; ?>">Policies (<?php echo $total_posts; ?>)</a></h3>
            <?php while (have_posts()) : the_post(); ?>
            <ul class="articles">
       	        <li class="article-entry standard"><h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
                <span class="article-meta"><?php the_modified_date('F j, Y'); ?> in  <?php the_category(', ') ?> </span>
                <span class="like-count"><?php echo get_total_likes($post->ID); ?></span>
                </li>
            </ul>
    	<?php endwhile;
        } ?>
    </section>
    
    <section class="span4 articles-list" style="margin-left:0;">
    <!-- References ID = 19-->
        <?php query_posts( array( 'category__and' => array($dept_id,19),
        'posts_per_page' => 5,
        'show_count' => 1 ) );
        $total_posts =$wp_query->found_posts;
        $myposts = $wp_query->post_count; 
    
        if ($myposts > 0) { ?>
            <h3><a href="/portal/?page_id=35?department_id=<?php echo $dept_id; ?>&department_name=<?php echo $deptname; ?>">References (<?php echo $total_posts; ?>)</a></h3>
            <?php while (have_posts()) : the_post(); ?>
            <ul class="articles">
       	        <li class="article-entry standard"><h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
                <span class="article-meta"><?php the_modified_date('F j, Y'); ?> in  <?php the_category(', ') ?> </span>
                <span class="like-count"><?php echo get_total_likes($post->ID); ?></span>
                </li>
            </ul>
    	<?php endwhile;
        } ?>
    </section>
    
    <section class="span4 articles-list">
    <!-- Recipes  ID = 18-->
        <?php query_posts( array( 'category__and' => array($dept_id,18),
        'posts_per_page' => 5,
        'show_count' => 1 ) );
        $total_posts =$wp_query->found_posts;
        $myposts = $wp_query->post_count; 
    
        if ($myposts > 0) { ?>
            <h3><a href="/portal/?page_id=37?department_id=<?php echo $dept_id; ?>&department_name=<?php echo $deptname; ?>">Recipes (<?php echo $total_posts; ?>)</a></h3>
            <?php while (have_posts()) : the_post(); ?>
            <ul class="articles">
                <li class="article-entry standard"><h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
                <span class="article-meta"><?php the_modified_date('F j, Y'); ?> in  <?php the_category(', ') ?> </span>
                <span class="like-count"><?php echo get_total_likes($post->ID); ?></span>
                </li>
            </ul>
    	<?php endwhile;
        } ?>
    </section>
    
    <section class="span4 articles-list">
    <!-- add new subject area here as needed -->
    </section>
    </div>
    </div>
                <!-- end of page content -->
                <?php get_sidebar('page'); ?>
            </div>
        </div>
    </div>
    <!-- End of Page Container -->
    <?php get_footer(); ?>
    Thread Starter thisismyalias

    (@thisismyalias)

    Hi. Thanks for the response. I have made sure I’m selecting the right Host Sidebar in Replace: Pages.

    The page templates I’m referring to are the ones that can be selected in the page editor. For example, I add a new page and select the custom page template (custom = I made it…my theme comes with templates that are not found in the core of WordPress though). The custom template is called “Departments”. The default sidebar for pages do appear on pages made with this template, but sidebars made with your plugin do not. The exact same sidebars work with every other template page aside from my custom ones.

    I’m not sure what you mean by “templates that are automatically loaded by your theme.”

    Thread Starter thisismyalias

    (@thisismyalias)

    I’ll update in the hopes that someone can add some insight.

    As a test I created a new custom page template by copying an origional theme template. I took template-faq.php (origional template) and renamed it template-test.php. I changed nothing about the file other than it’s name.

    I then created a new page using this template. The page inherits the page sidebar as expected. The plugin I’m using to create custom sidebars works on this new custom template.

    The thing that is different about my custom template that *isn’t* working with the plugin is the code between <!– Start of Page Container –> and <!– End of Page Container –> (although the <?php get_sidebar(‘page’); ?> is the same).

    I don’t understand how the code in the template would cause the sidebar plugin not to work…

    Thread Starter thisismyalias

    (@thisismyalias)

    Well, to follow up in case you read this, I see now that display_ca_siebar isn’t a solution to my problem.

    I have a custom template, which does display the Pages sidebar, just like other origional theme pages. However, the sidebars created with this plugin will not display on this custom template. It’s odd that sidebars work on the custom template, but not sidebars created with this plugin.

    I also discovered that the plugin does work with other custom pages – I took an origional theme page template (template-faq.php) and renamed it to create a custom page template. The plugin works on this custom template. This tells me that somehow the custom template that isn’t working has something in it that is messing things up.

Viewing 15 replies - 1 through 15 (of 24 total)