How to get Co-Author-Plus data via shortcode - wordpress

with the following code I want to show the authors via the Co-Author-Plus plugin via shortcode using a php file. But this doesnt work. It just returns nothing. You know why?
Update code:
<?php function coauthorplus_function() {
ob_start();
$coauthors = get_coauthors();
$len = count( $coauthors );
if ( (function_exists( 'coauthors_posts_links' )) && ($len > 1) ) { ?>
<div class="authors-container">
<div class="author-image">
<?php echo get_avatar( $coauthor->user_email, '80'); ?>
</div>
<div class="author-data-details">
<div class="fdescription fdescriptions">Dieser Artikel wurde in Ko-Produktion durch folgende Autoren erstellt:</div>
<div class="authors-name">Von <?php coauthors_posts_links(); ?></div>
</div>
<div class="clearfix"></div>
</div>
<?php
} else {
global $post;
$author_id=$post->post_author;
foreach( get_coauthors() as $coauthor ):
?>
<div class="author-container">
<div class="author-image">
<?php echo get_avatar( $coauthor->user_email, '80'); ?>
</div>
<div class="author-data-details">
<div class="author-name">Von <?php coauthors_posts_links(); ?></div>
<div class="fdescription"> <?php echo $coauthor->description; ?></div>
</div>
<div class="clearfix"></div>
</div>
<?php endforeach;
}
return ob_get_clean(); } add_shortcode('coauthorplus', 'coauthorplus_function'); ?>
In my function.php which is on the same place in the webspace I included the following:
include('coauthorplus.php');

Related

ACF repeater - apply different row last repeater

I use ACF repeater in my wordpress website.
Each repeater display in a col-md-6.
I would like to display the last in a col-md-12.
<div class="container">
<?php if ( have_rows( 'salon' ) ) : ?>
<div class="row">
<?php while ( have_rows( 'salon' ) ) : the_row(); ?>
<div class="col-md-6">
<div class="card">
<div class="card-body">
<h2 class="card-title">Card title</h2>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
</div>
Try this example with your code it's working for me.
<?php if( have_rows('services_repeater', $services) ): ?>
<?php $rowCount = count( get_field('services_repeater', $services) ); //GET THE COUNT ?>
<?php $i = 1; ?>
<?php while( have_rows('services_repeater', $services) ): the_row(); ?>
<?php // vars
$service = get_sub_field('service');
$description = get_sub_field('description');
?>
<span class="hint--bottom" data-hint="<?php echo $description; ?>"><?php echo $service; ?></span>
<?php if($i < $rowCount): ?>
<div id="separator"> / </div>
<?php endif; ?>
<?php $i++; ?>
<?php endwhile; ?>
<?php endif; ?>

WordPress footer above content

Sorry, I'm a complete newbie at this, My question may sound stupid to some.
I've taken over maintenance of a WordPress site done by another developer who's no longer reachable. I'm having trouble with getting the content to display properly on the following page https://www.covalin.com/product-category/boxes/metallic-boxes/, when I change the number of products to be shown on the page to anything higher than 9, then it pushes the footer to the middle of the page and shows products below the footer. I want to be able to all products under each subcategory. Please see the screenshots below in order to get an idea of the issue. Any guidance will be most appreaciated, I've spent hours trying to figure this out.
When I use the following CSS below, it partly solves the problem but creates another one where all of the content is scrollable but appears behind the footer.
CSS Code - used
.footer {
position: fixed;
bottom:0;
}
PHP Code which changes the number of products display, added by last dev:
/*---------- woo-product pagination number setting ------------*/
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value
stored on Options -> Reading
// Return the number of products you wanna show per page.
$cols = 27; //I changed this from 27 to 9 for the page to display properly.
return $cols;
}
How the site looks like with 9 products on a page
How the site looks like with 27 products on a page
Updated - with footer.php file below
<?php
/**
* The template for displaying the footer
*
* Contains footer content and the closing of the #main and #page div elements.
*
* #package WordPress
* #subpackage Twenty_Fourteen
* #since Twenty Fourteen 1.0
*/
?>
<?php // Check if site turned to boxed version
$boxed = ''; $boxed_element = ''; $row_class = '';
if (get_option('site_layout')=='boxed') {$boxed = 'container'; $boxed_element = 'col-md-12 col-sm-12'; $row_class = 'row';}
?>
<?php if ($boxed && $boxed!='') { ?>
</div>
<div class='row'>
<?php } ?>
<?php if ( class_exists('Woocommerce') ): ?>
<?php if(is_shop() || is_product() && is_active_sidebar('footer-bottom-shop')): ?>
<?php if (!$boxed || $boxed=='') : ?><div class="container">
<div class="row"><?php endif; ?>
<div class="shop-bottom-sidebar col-xs-12 col-sm-12 col-md-12">
<?php dynamic_sidebar('footer-bottom-shop'); ?>
</div>
<?php if (!$boxed || $boxed=='') : ?></div>
</div><?php endif; ?>
<?php endif ?>
<?php endif ?>
<footer id="colophon" class="site-footer <?php echo esc_attr($boxed_element);?>">
<?php
if (get_option('site_footer_top_background_option') && get_option('site_footer_top_background_option')!=''){
$site_footer_top_background_option = get_option('site_footer_top_background_option');
}
else{$site_footer_top_background_option='';}
?>
<?php if(is_active_sidebar('footer-top-sidebar-1') || is_active_sidebar('footer-top-sidebar-2')): ?>
<div class="footer-top widget-area <?php echo esc_attr($row_class);?>" style="background:<?php echo esc_attr($site_footer_top_background_option); ?>;">
<?php if (!$boxed || $boxed=='') : ?><div class="container">
<div class="row"><?php endif; ?>
<div class="col-xs-12 col-sm-6 col-md-6 footertopsidebarone">
<?php if(is_active_sidebar('footer-top-sidebar-1')): ?>
<?php dynamic_sidebar('footer-top-sidebar-1'); ?>
<?php endif;?>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 footertopsidebartwo">
<?php if(is_active_sidebar('footer-top-sidebar-2')): ?>
<?php dynamic_sidebar('footer-top-sidebar-2'); ?>
<?php endif;?>
</div>
<?php if (!$boxed || $boxed=='') : ?></div></div><?php endif; ?>
</div>
<?php endif; ?>
<?php
if (get_option('site_middle_background_option') && get_option('site_middle_background_option')!=''){
$site_middle_background_option = get_option('site_middle_background_option');
}
else{$site_middle_background_option='';}
?>
<div class="footer-middle widget-area <?php echo esc_attr($row_class);?>" style="background:<?php echo esc_attr($site_middle_background_option);?>">
<?php if (!$boxed || $boxed=='') : ?><div class="container">
<div class="row"><?php endif; ?>
<?php
if (get_option('footer_bg_img') && get_option('footer_bg_img')!=''){
$footer_bg_img_url = get_option('footer_bg_img');
}
else{$footer_bg_img_url='';}
if (get_option('footer_bg_img_position') && get_option('footer_bg_img_position')!=''){
$footer_bg_img_position = get_option('footer_bg_img_position');
switch($footer_bg_img_position){
case "right":
$storex_footer_bg_position='96%';
break;
case "left":
$storex_footer_bg_position='4%';
break;
}
}
else{$storex_footer_bg_position='';}
?>
<div class="fotter-bg-img" style="background: url(<?php echo esc_url($footer_bg_img_url)?>) no-repeat transparent; background-position:<?php echo esc_attr($storex_footer_bg_position)?> 90%">
<div class="col-xs-12 col-sm-6 col-md-3">
<?php if ( is_active_sidebar( 'footer-sidebar-1' ) ) : ?>
<?php dynamic_sidebar( 'footer-sidebar-1' ); ?>
<?php endif; ?>
</div>
<div class="col-xs-12 col-sm-6 col-md-3">
<?php if ( is_active_sidebar( 'footer-sidebar-2' ) ) : ?>
<?php dynamic_sidebar( 'footer-sidebar-2' ); ?>
<?php endif; ?>
</div>
<div class="col-xs-12 col-sm-6 col-md-3">
<?php if ( is_active_sidebar( 'footer-sidebar-3' ) ) : ?>
<?php dynamic_sidebar( 'footer-sidebar-3' ); ?>
<?php endif; ?>
</div>
<div class="col-xs-12 col-sm-6 col-md-3">
<?php if ( is_active_sidebar( 'footer-sidebar-4' ) ) : ?>
<?php dynamic_sidebar( 'footer-sidebar-4' ); ?>
<?php endif; ?>
</div>
</div>
<?php if (!$boxed || $boxed=='') : ?></div>
</div><?php endif; ?>
</div>
<?php
if (get_option('site_footer_bottom_background_option') && get_option('site_footer_bottom_background_option')!=''){
$site_bottom_background_option = get_option('site_footer_bottom_background_option');
}
else{$site_bottom_background_option='';}
?>
<div id="footer-bottom" style="background:<?php echo esc_attr($site_bottom_background_option); ?>;" class="<?php echo esc_attr($row_class);?> footer-bottom">
<?php if (!$boxed || $boxed=='') : ?><div class="container">
<div class="row"><?php endif; ?>
<div class="col-xs-12 col-sm-6 col-md-6">
<?php if (has_nav_menu('footer-nav')) : ?><!-- Footer navigation -->
<nav id="site-navigation-footer" class="footer-navigation">
<?php wp_nav_menu( array('theme_location' => 'footer-nav') ); ?>
</nav>
<?php endif; ?><!-- Footer navigation -->
<div class="site-info">
<?php $copyright = esc_attr(get_option('site_copyright'));
if ($copyright != '') {
echo esc_attr($copyright);
} else {
echo 'Storex © '.date('Y') .''.esc_html__(' Theme by Themes Zone. All rights reserved', 'storex');
}
?>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6">
<?php if ( is_active_sidebar( 'footer-bottom' ) ) : ?>
<?php dynamic_sidebar( 'footer-bottom' ); ?>
<?php endif; ?>
</div>
<?php if (!$boxed || $boxed=='') : ?></div>
</div><?php endif; ?>
</div>
</footer><!-- #colophon -->
<?php if ($boxed && $boxed!='') { ?>
</div>
<?php } ?>
</div><!-- #page -->
<script>
jQuery( document ).ready(function() {
jQuery('.quantity').append("<span class='qty-cus'>Qty</span>");
jQuery('.wc-forward').val('View Order');
jQuery('.update_cart').val('Update Order');
});
//review order table text changes
jQuery(window).on('load',function(){
setTimeout(function() { //calls click event after a certain time
jQuery('.cart-subtotal th').text('Order SubTotal');
}, 3000);
jQuery('.update_cart').val('Update Order');
jQuery('.page-template-special-offer .header-stripe h1.title').text('SPECIAL OFFERS');
jQuery('.product-description-wrapper > .quantity').remove();
});
var cloned_field = jQuery('.register p.form-row.full').clone();
jQuery('#custom_fax_no').append(cloned_field);
jQuery('.register p.form-row.full').eq(0).remove();
jQuery(window).scroll(function(){
var winScroll= jQuery(window).scrollTop();
console.log(winScroll);
if(winScroll>0){
jQuery('.header-top').addClass('sticky');
}else{
jQuery('.header-top').removeClass('sticky');
}
});
</script>
<?php wp_footer(); ?>
</body>
</html>
The issue is that you are not closing the <div> properly.
Currently it is like
<div id="page" class="hfeed site container">
<div class='row custom_header'>
<!-- some contents..... -->
</div>
<div class='row'>
<div id="main" class="site-main col-md-12 col-sm-12">
<!-- some contents..... -->
</div>
<div class='row'>
<footer id="colophon" class="site-footer col-md-12 col-sm-12">
<!-- some contents... -->
</footer>
</div>
</div>
</div>
It should be like,
<div id="page" class="hfeed site container">
<div class='row custom_header'>
<!-- some contents... -->
</div>
<div class='row'>
<div id="main" class="site-main col-md-12 col-sm-12">
<!-- some contents... -->
</div>
</div>
<div class='row'>
<footer id="colophon" class="site-footer col-md-12 col-sm-12">
<!-- some contents... -->
</footer>
</div>
</div>
There is no need to change the CSS.

WP_Query change code

In my theme WordPress to display the post uses this (code #1):
function inner($posts, $td_column_number = '') {
$buffy = '';
if (!empty($posts)) {
foreach ($posts as $post) {
$td_module_17 = new td_module_17($post);
$buffy .= $td_module_17->render($post);
}
}
return $buffy;
}
I need to show posts using this code (code #2):
<?php
$custom_query = new WP_Query('posts_per_page= 5');
while($custom_query->have_posts()):
$custom_query->the_post();
?>
<div class="post-1">
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<h3><?php the_title(); ?></h3>
<div class="float-tags">
<div class="bb-td-post-small-box clearfix">
<?php the_tags('','',''); ?>
</div>
</div>
<div class="post-2">
<?php the_content(); ?>
</div>
</div>
</div>
<?php
endwhile;
wp_reset_postdata(); // reset the query
?>
If I insert code #2 into module 17, then the posts are output immediately all in one block, and not one at a time.
Solved a problem. The code was looped. Here is the working code.
<?php
class td_module_17 extends td_module {
function __construct($post) {
//run the parrent constructor
parent::__construct($post);
}
function render($Post = false) {
ob_start();
?>
<div class="post-1">
<div
<?php //post_class(); ?> id="post-<?= $Post->ID; ?>">
<h3><?= $Post->post_title; ?> </h3>
<div class="float-tags">
<div class="bb-td-post-small-box clearfix">
<?php $tags = get_the_tags($Post->ID); ?>
<? foreach ($tags as $tag) : ?>
<?= $tag->name; ?>
<? endforeach; ?>
</div>
</div>
<div class="post-2">
<?= apply_filters('the_content', $Post->post_content); ?>
</div>
</div>
</div>
<?php return ob_get_clean();
}
}

ACF Odd/Even Alternate Layout with Relationship

I'm trying to create a two column element using ACF repeater fields. The only thing is I'm trying to alternate this so that the content in the two columns switches left/right depending on the row being even or odd.
The output will look something like:
This is how I looped:
<section id="projects" class="container specific-margin-1">
<!-- Repeater -->
<div class="row">
<?php $i=0 ; if(get_field( 'featured_projects')): ?>
<?php while(has_sub_field( 'featured_projects')): $i++; ?>
<div class="row">
<?php
/*
* Loop through post objects (assuming this is a multi-select field) ( setup postdata )
* Using this method, you can use all the normal WP functions as the $post object is temporarily initialized within the loop
* Read more: http://codex.wordpress.org/Template_Tags/get_posts#Reset_after_Postlists_with_offset
*/
$post_objects = get_field('featured_projects');
if($post_objects ): ?>
<ul>
<?php foreach( $post_objects as $post): // variable must be called $post (IMPORTANT) ?>
<?php setup_postdata($post); ?>
<div class="repeater_row <?php if (($i % 2)==0 ): ?>col-lg-3 col-md-4 col-sm-6<?php else: ?>col-lg-9 col-md-8 col-sm-6<?php endif; ?>">
<?php if (($i % 2)==0 ): ?>
<li>
<h3><?php the_title(); ?></h3>
<h3><?php the_field('project_location'); ?></h3>
<br>
<span><?php the_field('project_area'); ?></span><br>
<span><?php the_field('project_scale'); ?></span><br>
<br>
<span style="color:#EE1601;">Explore this project <i class="fa fa-arrow-circle-right" aria-hidden="true"></i></span>
</li>
<?php else:
// check if the post has a Post Thumbnail assigned to it.
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
?>
<?php endif; ?>
</div>
<div class="repeater_row <?php if (($i % 2)==0 ): ?>col-lg-9 col-md-8 col-sm-6<?php else: ?>col-lg-3 col-md-4 col-sm-6<?php endif; ?>">
<?php if (($i % 2)==0 ): ?>
<?php // check if the post has a Post Thumbnail assigned to it.
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
?>
<?php else: ?>
<li>
<?php // check if the post has a Post Thumbnail assigned to it.
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
?>
<h3><?php the_title(); ?></h3>
<h3><?php the_field('project_location'); ?></h3>
<br>
<span><?php the_field('project_area'); ?></span><br>
<span><?php the_field('project_scale'); ?></span><br>
<br>
<span style="color:#EE1601;">Explore this project <i class="fa fa-arrow-circle-right" aria-hidden="true"></i></span>
</li>
<?php endif; ?>
</div>
<?php endforeach; ?>
</ul>
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
<?php endif;?>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
<!-- Repeater -->
</section>
My Current Output looks like this:
This is the minimal logic for having alternate image and text row wise.
<div class="container">
<div class="row">
<?php
for ($i = 1; $i <= 10; $i++)
{
//even counter will have right image
if ($i % 2 == 0)
{
?>
<div class="col-md-12">
<div class="col-md-4">
Title Number: <?php echo $i; ?>
</div>
<div class="col-md-8">
<img src="" class="img-responsive"/>
</div>
</div>
<?php
}
//odd counter will have left image
else
{
?>
<div class="col-md-12">
<div class="col-md-8">
<img src="" class="img-responsive"/>
</div>
<div class="col-md-4">
Title Number: <?php echo $i; ?>
</div>
</div>
<?php
}
}
?>
</div>
</div>
Hope this will give you an idea.

Custom template for category WordPress

Hello I'm new in WordPress custom templates. Can anybody tell me how I can load a different template for a category.
Here is the index.php file
<?php
/**
* The main template file
*
* No comment for now
*
* #package WordPress
* #subpackage site
* #since site
*/
get_header(); ?>
<?php
$strFr='Featured';
$strFinancial='Financial Reports';
$strResearch='Research';
?>
<div id="page-body" role="main">
<div class="container">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12 SearchTop">
<form role="search" method="get" id="searchform" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-search"></i></div>
<input type="text" value="<?php echo get_search_query(); ?>" name="s" id="s" class="form-control customsearchfiled" placeholder="Search of anything related to Site" />
</div>
</form>
</div><!-- SearchTop -->
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="col-md-12 col-sm-12 col-xs-12 mb20 no-gutter">
<div class="col-md-12 col-sm-12 col-xs-12 no-gutter">
<?php if (have_posts()) : ?>
<?php /* Start the Loop */ ?>
<?php while (have_posts()) : the_post(); ?>
<?php get_template_part('content', get_post_format()); ?>
<?php endwhile; ?>
<?php else : ?>
<article id="post-0" class="post no-results not-found">
<?php if (current_user_can('edit_posts')) :
// Show a different message to a logged-in user who can add posts.
?>
<header class="entry-header">
<h1 class="entry-title mt20"><?php _e('No posts to display', 'twentytwelve'); ?></h1>
</header>
<!--<div class="entry-content">
<p><?php //printf(__('Ready to publish your first post? Get started here.', 'twentytwelve'), admin_url('post-new.php')); ?></p>
</div> .entry-content -->
<?php else :
// Show the default message to everyone else.
?>
<header class="entry-header">
<h1 class="entry-title"><?php _e('Nothing Found', 'twentytwelve'); ?></h1>
</header>
<div class="entry-content">
<p><?php _e('Apologies, but no results were found. Perhaps searching will help find a related post.', 'twentytwelve'); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
<?php endif; // end current_user_can() check ?>
</article><!-- #post-0 -->
<?php endif; // end have_posts() check ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
As far I know the index file is calling content php file that shows the post layout but don't know how to do this. Tried a lot of things but only get php error. I don't know php syntax much
<?php
/**
* Custom template with better structure than WP default.
*
* Used for both single and index/archive/search.
*
* #package WordPress
* #subpackage site
* #since Site 1.0
*/
# for one post
if (is_single()) {
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php if(function_exists('pf_show_link')){echo pf_show_link();} ?>
<p class="text-center topcategory">
<?php foreach((get_the_category()) as $category) {
echo $category->cat_name . ' ';
}
?>
</p>
<h1 class="entry-title"><?php the_title(); ?></h1>
<p class="postmetadown">By :<span class="bluecolor"><?php the_author(); ?></span> | <span><?php the_date() ?></span></p>
</header>
<div class="entry-content col-md-9 col-sm-9 col-xs-12">
<?php the_content(__('Continue reading <span class="meta-nav">→</span>', 'twentytwelve')); ?>
<?php wp_link_pages(array('before' => '<div class="page-links">' . __('Pages:', 'twentytwelve'), 'after' => '</div>')); ?>
</div>
<div class="col-md-3 col-sm-3 col-xs-12">
<?php get_sidebar(); ?>
</div>
<?php if (comments_open()) : ?>
<!--<div id="disqus_thread"></div>

<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'site'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function () {
var dsq = document.createElement('script');
dsq.type =
'text/javascript';
dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')
[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/? ref_noscript">comments powered
by Disqus.</a></noscript>
comments powered by <span class="logo- disqus">Disqus</span>-->
<?php endif; ?>
<footer class="entry-meta col-md-12">
<?php if ($googlePlusAcc = get_the_author_meta('googleplus')) { ?>
<?php hr_single_entry_meta(); ?>
<?php } else { ?>
<?php twentytwelve_entry_meta(); ?>
<?php } ?>
<?php edit_post_link(__('Edit', 'twentytwelve'), '<span class="edit-link">', '</span>'); ?>
<?php if (is_singular() && get_the_author_meta('description') && is_multi_author()) : // If a user has filled out their description and this is a multi-author blog, show a bio on their entries. ?>
<div class="author-info">
<div class="author-avatar">
<?php
/** This filter is documented in author.php */
$author_bio_avatar_size = apply_filters('twentytwelve_author_bio_avatar_size', 68);
echo get_avatar(get_the_author_meta('user_email'), $author_bio_avatar_size);
?>
</div>
<!-- .author-avatar -->
<div class="author-description">
<h2><?php printf(__('About %s', 'twentytwelve'), get_the_author()); ?></h2>
<p><?php the_author_meta('description'); ?></p>
<div class="author-link">
<a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?>"
rel="author">
<?php printf(__('View all posts by %s <span class="meta-nav">→</span>', 'twentytwelve'), get_the_author()); ?>
</a>
</div>
</div>
</div>
<?php endif; ?>
</footer>
</article>
<?php
#for listing page
} else {
$category = get_the_category();
if (!empty($category))
$category = $category[0];
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php //if (is_sticky() && is_home() && !is_paged()) : ?>
<!--<div class="featured-post">
<?php //_e('Featured post', 'twentytwelve'); ?>
</div>-->
<?php //endif; ?>
<div class="col-md-4 col-sm-4 col-xs-12 categoryimg no-gutter">
<?php if (has_post_thumbnail()) { ?>
<div class="post-thumbnal-wrapper-multiple">
<?php the_post_thumbnail(); ?>
</div>
<?php } ?>
</div>
<div class="col-md-8 col-sm-8 col-xs-12 categoryContent">
<header class="entry-header">
<h1 class="entry-title">
<?php the_title(); ?>
</h1>
</header>
<?php if (is_search()) : // Only display Excerpts for Search ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div>
<?php else : ?>
<div class="entry-content">
<?php the_excerpt_more(); ?>
</div>
<?php endif; ?>
<div class="col-md-12">
<footer class="entry-meta">
<?php twentytwelve_entry_meta(); ?>
<?php edit_post_link(__('Edit', 'twentytwelve'), '<span class="edit-link">', '</span>'); ?>
</footer>
</div>
</div><!-- categoryContent -->
</article>
<div class="clearfix"></div>
<?php
}
If you want a template for the category page, see https://codex.wordpress.org/Category_Templates. If you want a different template for the content, based on the category, you could use (in your content.php)
<?php if (is_category('Category A')) : ?>
<p>This is the text to describe category A</p>
<?php elseif (is_category('Category B')) : ?>
<p>This is the text to describe category B</p>
<?php else : ?>
<p>This is some generic text to describe all other category pages,
I could be left blank</p>
<?php endif; ?>
If there's a lot of difference between categories, I would place this in index.php, and create different templates for every category
Check out this page Template Hierachy. Basically if you want to target a specific category you create a file like so category-{slug}.php {slug} being the category slug you want to target.
I suggest you to read about Wordpress Template Hierarchy in https://developer.wordpress.org/themes/basics/template-hierarchy/
To answer your question, you need to create a category-{id}.php or category-{slug}.php file. in your theme folder (Choose only one)
id = your category ID
slug = your category slug
After creating the file, then you can put your custom code if you want.
Add your code inside archive.php which will list all the posts in the category and add the detail page template inside single.php .
https://codex.wordpress.org/Category_Templates

Resources