Hi all.
I’m familiar with coding but I don’t know php nor much WordPress.
I have a custom plugin which counts the # of posts in a blog and injects the Post Title and Post # into the top of the post before displaying it. I want to add a conditional test, causing it to only add the Title and Post # to posts that have a Post # below a defined threshold.
Current File: single-questions.php:
<?php
/**
* The custom questions post type template
*/
//Add featured image above post
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
add_action( 'genesis_before_entry', 'minimum_questions_grid' );
function minimum_questions_grid() {
echo '<div class="questions-image">'. get_the_post_thumbnail( $id, array(110,110) ).'</div>';
}
add_filter( 'genesis_post_info', 'ck_new_post_info' );
function ck_new_post_info( $post_info ) {
global $post;
$post_id = $post->ID;
$args = array (
'post_type' => array( 'questions' ),
'order' => 'ASC',
'orderby' => 'date',
'posts_per_page' => '-1',
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
$counter = 0;
while ( $query->have_posts() ) {
$counter++;
$query->the_post();
if ($post->ID == $post_id) $counter_text = "CQ #" . $counter . " - ";
}
} else {
// no posts found
}
wp_reset_postdata();
$post_info = $counter_text . "[post_date]";
return $post_info;
}
//* Remove the entry meta in the entry footer
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
//* Run the Genesis loop
genesis();
The modification in pseudo code:
$threshold = 107;
If (CQW# < $threshold) {
inject Title and Post # (what we are currently doing)
} else {
don’t inject Title and Post #
}
Thanks in advance for assistance.