Ich kann nicht auf meine Variablen innerhalb meiner Vorlagendatei zugreifen (siehe Kommentar unten). danke im voraus für die Hilfe.Wie kann ich eine Variable von functions.php an die Vorlagendatei in WordPress übergeben?
functions.php:
$mypage = (get_query_var('paged')) ? get_query_var('paged') : 1;
$maxpost = $loop->max_num_pages;
template.php:
$args = array(
'post_type' => 'publications',
'posts_per_page' => 2,
);
$query = new WP_Query($args); ?>
<?php if ($query->have_posts()) : ?>
<div id="posts">
<?php while ($query->have_posts()) : $query->the_post(); ?>
<section class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 publications-section tagged-posts post">
<?php if (has_post_thumbnail()) : ?>
<a href="<?php echo get_permalink($post->ID); ?>">
<div class="col-sm-4 col-sm-push-8 publications-section-image" style="background-image:url('<?php the_post_thumbnail_url(); ?>');"></div>
</a>
<?php endif; ?>
<div class="col-sm-8 col-sm-pull-4">
<h2><a href="<?php echo get_permalink($post->ID); ?>"><?php the_title(); ?></a></h2>
<p><?php the_excerpt(); ?></p>
<small><?php echo get_post_meta($post->ID, "_contact", true); ?></small>
<small class="pub-tags pub"> <span><?php the_terms($post->ID,'mytag','',' '); ?></span></small>
</div>
</section>
<?php echo $mypage; endwhile; wp_reset_postdata(); ?>
</div>
<div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2" id="pub-btn-section">
<input type="submit" class="btn" id="loadmore" name="" value="Submit">
</div>
<?php endif; ?>
zeigen Sie den vollständigen Code von functions.php an, welchen Hook verwenden Sie für den Code von functions.php. –