Jump to content

Recommended Posts

Hey,

i have a page with a php script which can show all articles on each category. Like here: https://coinfeeds.de/category/sol

category.php is like this

<?php block('content'); ?>
<div class="container px-md-1 mt-3">
 <?= breadcrumb_render('<ol class="breadcrumb my-1 px-2">', '</ol>'); ?>
  <div class="row no-gutters">
  
    <div class="col-md-12 col-lg-8 px-0 px-md-2">
         <?php if (has_items($t['latest_posts'])) : ?> 
            <div class="row">
                <?php foreach ($t['latest_posts'] as $t['loop']) : ?>
                
                            <?php insert('partials/loopnew.php'); ?>
              
            <?php endforeach; ?>
        </div>

        
            <?= $t['pagination_html']; ?>
              <div class="mb-4"></div>
        <?php else : ?>
                <?php
                insert(
                    'partials/empty.php',
                    [
                        'empty_message' => __('no-posts-found-home', _T)
                    ]
                );
                ?>
        <?php endif; ?>
    </div>
   <div id="hidden-xs"><div class="col-4 col-md-12 col-lg-12 p-0 px-md-2">
        <div class="sidebar sidebar-right">
        <?php insert('partials/site_sidebar_right_cat.php'); ?>
    </div></div>
    </div>
    </div>
  </div>
<?php endblock(); ?>

<?php
extend(
    'layouts/basic.php',
    [
    'body_class' => 'category',
    ]
);

and loopnew.php like this

<?php
/**
 * Fires before basic news loop
 */
do_action('news_loop_before');
?>

   <div class="col-md-4">
              <div class="card mb-4 box-shadow">
                <a href="<?= e_attr(post_url($t['loop'])); ?>" class="post-img-link" <?= post_attrs($t['loop']); ?>><img class="card-img-top" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFElEQVQYV2N8+vTpfwYGBgZGGAMAUNMHXwvOkQUAAAAASUVORK5CYII=" data-src="<?= e_attr(feat_img_url($t['loop.post_featured_image'])); ?>" alt="<?= e_attr($t['loop.post_title']); ?>" class="post-feat-img img-zoom"></a>
                <div class="card-body h-100">
                    <div class="post-title-category mt-2 pb-1"><?= e_attr($t['loop.category_name']) ?></div>
                    <div class="post-title pb-1" title="<?= e_attr($t['loop.post_title']); ?>">
               <a href="<?= e_attr(post_url($t['loop'])); ?>" <?= post_attrs($t['loop']); ?>> <?= e(limit_string($t['loop.post_title'], 68), false); ?></a>
            </div>
                  <p class="card-text pb-1"><?= e(limit_string($t['loop.post_excerpt'], 80), false); ?></p>
                  <div class="d-flex justify-content-between align-items-center">
                    <div class="btn-group">
                      <span class="badge badge-cat"><i class="fas fa-newspaper"></i> <?= e_attr($t['loop.feed_name']) ?></span> 
                    </div>
                    <small class="text-muted">vor <?= time_ago($t['loop.post_pubdate'], _T); ?></small>
                </div>
              </div>
            </div></div>

<?php
/**
 * Fires after basic news loop
 */
do_action('news_loop_after');
?>
 
<?php
$t['__loop'] = $t['__loop'] + 1;

if ($t['__loop'] === 4) :
    $t['__loop'] = 0;
    ?>
<div class="adblock">
    <?= get_option('ad_unit_3'); ?>
</div>
<?php endif; ?>

 

Now i try to echo the articles from a category on a different page.

 $catId = 1;
 $filters['where'][] = ["{$postsTable}.post_category_id", '=', $catId];

 

But i m not a php coder, maybe you can give me some tipps how i can reach my plan.
Thank you for your time!

1 hour ago, paulmagm said:

Now i try to echo the articles from a category on a different page.

You try to echo the articles on a different page and... what? What happens? And given that you're doing this on a different page, is the code for category.php or loopnew.php even relevant?

2 minutes ago, requinix said:

You try to echo the articles on a different page and... what? What happens? And given that you're doing this on a different page, is the code for category.php or loopnew.php even relevant?

I have no idea how it could work. maybe someone can give me some tipps how i can output the last loop of a category.

I don't want to go thru your html to find out the truth of this issue.  Can you perhaps step back from programming and put on your real-world hat and tell us what you  want to do?  In real-world terms as your boss probably described to you.  Is this an inventory review app?  A sales-point app?  What do you want the user to be able to do?  And please, please don't use screen/page/script/etc. in your explanation.  Just person-to-person, not coder-to-coder.

Are you giving up?  Say it ain't so...

The thread wasn't getting us anywhere and your use of terms was confusing.  For one - pages don't have scripts.. Scripts produce pages.

Let's just start a conversation about something you want to do.  In non-nerd speak.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.