• Hello,

    We use WP as a “backend” for posting to our website. This works fine with categories that don’t generate many static posts. We do have on page, however, that posts audio each week. The audio is static and remains on the page forever. This is getting to be a problem with loading all the audio. I would like to post the audio, limit the amount per page and provide pagination. Our current Loop code doesn’t provide this option. I’ll post our code below – I’m hoping someone can help us modify it to allow for the post limit and pagination. Thanks!

    Before any code on .php page:

    <?php require('../post/wp-blog-header.php'); $infocus = new wp_query('cat=2402&showposts=10');?>
    

    The loop to display the posts:

    <?php while ($infocus->have_posts()): $infocus->the_post(); ?>
    
                <div class="focus-post">
                    <h2><?php the_title(); ?></h2>
    
                    <?php the_content (); ?>
                </div>
    
                <?php endwhile; ?>

    I have tried pasting different pagination code I’ve found but it doesn’t work – when you click the “Next” we generally get a “404”.

    Thanks!

    • This topic was modified 3 years, 6 months ago by daf57.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter daf57

    (@daf57)

    Basically what I’m looking for is the format you get when you click on the category link in a theme – but it needs to look like our website. So maybe it would be easier to customize the category template? Thing is, I can’t really find the template used for that. There isn’t a “category.php” in our theme (twentyfifiteen).

    Thread Starter daf57

    (@daf57)

    I found the category template, as archive.php, I can modify it as needed to get the results I want.

    Thanks
    Daf

    Moderator bcworkz

    (@bcworkz)

    ETA: You posted about archive.php while I was interrupted elsewhere while composing this reply. There’s more info in my reply you may still find useful.

    ————————–
    If no category.php, either archive.php or index.php is used.
    https://developer.www.ads-software.com/themes/basics/template-hierarchy/#category

    You can always add a category.php template if you don’t want to modify archive.php. Added templates should be kept in a child theme.

    If you really want WP posts on your main site, post data can be fetched through the REST API. Post data in JSON format is returned. Your site’s code would then parse the data and create the page content. You may be right though, altering the WP page to look just like your main site is likely easier.

    • This reply was modified 3 years, 6 months ago by bcworkz.
    Thread Starter daf57

    (@daf57)

    Hey thanks! I did end up using a category-slug template and that’s going to work fine.
    The only problem there is that the link to that page. I wanted a directory index (like ktbb.com/infocus) but with the category template it’s more like ktbb.com/wpdirectory/cat=xxx

    May be a way to cloak or redirect – haven’t looked into that yet.

    Thanks again!

    Moderator bcworkz

    (@bcworkz)

    /wpdirectory/category/foo/ should work for category archive requests (category foo in this example)

    If you find a need for some unusual permalink structure, add_rewrite_rule() can help you define it.

    Thread Starter daf57

    (@daf57)

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Display Category Posts on Non WP website’ is closed to new replies.