Grow your CSS skills. Land your dream job.

page loop issue

  • # October 30, 2012 at 9:08 pm

    I have a query set up for the posts. All the pages are being displayed right now on the main site (as I want, it was intended to be one long page). The pages however are not querying. I could not find how to grab the page info rather then post info.

    http://www.jtpenezich.com/abc/

    That is the page (in a nutshell, still needs actual design work) the nav at the top reflects the pages I created. Which are all below the twitter feed. Each heading you see after the twitter feed is its own page.

    # October 30, 2012 at 9:09 pm

    Should be as simple as doing this for the query:

    query_posts( ‘post_type=page&orderby=title&order=DESC’ );

    …or whatever options you want.

    And you don’t need to use the slug at all for an identifier, you can just use the ID like you did above:

    # October 30, 2012 at 9:10 pm

    I think the main thing is that you were still querying posts, not pages.

    # October 30, 2012 at 9:11 pm

    Well the pages are being displayed. The post query was fine and needed nothing changed. The pages used a default loop that was not a query. I took it from a one-col template and added it into the index page and then made the index a static page.

    # October 30, 2012 at 9:12 pm

    @TheDoc Ah ha! I was looking for this `< ?php the_ID(); ?>`

    # October 30, 2012 at 9:18 pm

    See below

    # October 30, 2012 at 9:40 pm

    < ?php $custom_query = new WP_Query('post_type=page&order=ASC');
    while($custom_query->have_posts()) : $custom_query->the_post(); ?>

    http://www.jtpenezich.com/abc/ That is what I was aiming for. Figured you may want to see. Also trimmed it down a bit to avoid so many unused classes. Thanks again

    # October 30, 2012 at 9:45 pm

    Make sure your div that uses `the_ID()` is *inside* of your loop.

    Glad you got it sorted!

    # October 30, 2012 at 9:51 pm

    @Jeager Is it adding a `

    ` tag inside the content? You can remove that by adding the code below to your functions.php file.

    // REMOVES

    TAG FROM POST CONTENT
    remove_filter( ‘the_content’, ‘wpautop’ );

    # October 30, 2012 at 9:54 pm

    Yes it was, and that function worked great. And yeah I had the ID outside but noticed it giving a ton of extra classes and an extra page wrap. Fixed now to where every page is inside the proper wrap and given its own class.

    All that is left for functionality is to see if I can somehow change the nav to go directly to the page. If not, I’ll just stick with the custom menu so everything goes to the anchor I tell it to.

    # October 30, 2012 at 10:04 pm

    @Jeager If it’s a one-page site why would it need to switch pages?

    # October 30, 2012 at 10:16 pm

    It does not. How it is set-up right now it jumps to an anchor lower on the page, which I added into the content of each page and given a name. I’m trying to see if I can find a more dynamic way of doing that. Also since my nav is fixed up top, I need it to jump to the anchor but -50px or so. I achieved this in mockups without wordpress by giving the anchor position:absolute and then forcing it to the top of the parent page element. But trying to… wordpressify it.

    # October 30, 2012 at 10:26 pm

    So like this…

    “> < ?php the_title(); ?>

    returns me the name of the title. Now I don’t have to manually ad an anchor inside each of the pages content. However I still have to manually add a menu item and then link it to said anchor. But this automates the process a bit. Thanks to you guys for giving me the idea. You can give class and ID’s, so I figured why not names also? But still need to push it up a bit so You can see the full page and title when you use the nav.

    # October 30, 2012 at 10:36 pm

    So, taking that a step forward. I have that anchor set above the heading. It will automatically create an anchor with the name of the title and .ap, while staying inside the .page of each “page” (which I am just treating as content for the site).

    ” class=”ap”>

    Afterwards I can then tell my nav to link to #whatever the name is of the anchor (which is the title of each section)

    And since each page has a padding-top of 100px to divide the content, the .ap class is position:absolute; top:0. Which makes it so it won’t hide the content you click to navigate to. This little experiment made me have a sudden realization of what some basic php can do.

    # October 31, 2012 at 12:17 am

    @Jeager Or you can just use jQuery to jump to the specific anchor points unless I’m misunderstanding (again).

Viewing 15 posts - 16 through 30 (of 31 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".