Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End page loop issue

  • This topic is empty.
Viewing 15 posts - 16 through 30 (of 31 total)
  • Author
    Posts
  • #112978
    Jeager
    Member

    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.

    #112979
    TheDoc
    Member

    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:

    #112980
    TheDoc
    Member

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

    #112981
    Jeager
    Member

    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.

    #112982
    chrisburton
    Participant

    @TheDoc Ah ha! I was looking for this ``

    #112983
    Jeager
    Member

    See below

    #112988
    Jeager
    Member

    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

    #112989
    TheDoc
    Member

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

    Glad you got it sorted!

    #112985
    chrisburton
    Participant

    @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’ );

    #112986
    Jeager
    Member

    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.

    #112990
    chrisburton
    Participant

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

    #112991
    Jeager
    Member

    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.

    #112992
    Jeager
    Member

    So like this…

    “>

    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.

    #112993
    Jeager
    Member

    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.

    #112996
    chrisburton
    Participant

    @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)
  • The forum ‘Back End’ is closed to new topics and replies.