- NewspaperPosts Loop Element
- NewspaperFlex Block Builder and Flex Loop Builder
- Apitd_api_category_top_posts_style::update_key
- Apitd_api_category_top_posts_style::update
- Apitd_api_category_top_posts_style::add
- NewspaperBookmark – Save For Later
- NewspaperModules Builder in Newspaper Theme
- NewspaperFilters and sorting for taxonomies
- NewsmagPage templates
- NewspaperPage templates
- NewspaperSmart Sidebar
- NewspaperChild Theme Support
- ApiAPI – Thumbnail – Introduction
- ApiAPI – Category top section style – Introduction
Hi,
The content of the post is loaded in the loop-single files, each post template has a corresponding loop-single file
– https://www.screencast.com/t/5qglKrJ4PT3f
The corresponding function would be here
– https://www.screencast.com/t/yZPq7EzHvkz
For posts there are options for 3 ads to be placed, at the moment
– https://forum.tagdiv.com/article-ads/
If you use a CPT you can use one of the post templates for it
– https://forum.tagdiv.com/custom-post-type-support/
These posts will not have the same settings as normal posts however.
Thanks
Authors I want the author’s picture, author name, and last post to be published in the blog.
I could not edit the codes in the file.
td_block_authors.php
If you add any code to this file, the last post of the author appears.
I’m glad you helped me urgently.
File:
<?php
class td_block_authors extends td_block {
/**
* Disable loop block features. This block does not use a loop and it dosn’t need to run a query.
*/
function __construct() {
parent::disable_loop_block_features();
}
function render($atts, $content = null) {
parent::render($atts);
global $wpdb;
$sort = ”;
extract(shortcode_atts(
array(
‘roles’ => ”,
‘sort’ => ”,
‘exclude’ => ”,
‘include’ => ”
), $atts));
//print_r($atts);
//die;
$get_users_array = array();
if (!empty($exclude)) {
$exclude_array = explode(‘,’, $exclude);
$get_users_array[‘exclude’] = $exclude_array;
}
if (!empty($include)) {
$include_array = explode(‘,’, $include);
$get_users_array[‘include’] = $include_array;
}
if (empty($sort)) {
$get_users_array[‘orderby’] = ‘display_name’;
//$td_authors = get_users(array(‘orderby’ => ‘display_name’));
} else {
$get_users_array[‘orderby’] = ‘post_count’;
$get_users_array[‘order’] = ‘DESC’;
//$td_authors = get_users(array(‘orderby’ => ‘post_count’, ‘order’ => ‘DESC’));
}
if (!empty($roles)) {
$roles_in = array();
$roles_buffer = explode(‘,’, $roles);
foreach ($roles_buffer as $role) {
//clear the empty space
$roles_in[] = trim($role);
}
//role__in was added in wp 4.4
$get_users_array[‘role__in’] = $roles_in;
}
$td_authors = get_users($get_users_array);
$buffy = ”;
$buffy .= ‘<div class=”‘ . $this->get_block_classes(array(‘td_top_authors’)) . ‘” ‘ . $this->get_block_html_atts() . ‘>’;
//get the block js
$buffy .= $this->get_block_css();
$buffy .= $this->get_block_title();
$buffy .= $this->get_pull_down_filter();
if (!empty($td_authors)) {
foreach ($td_authors as $td_author) {
//echo td_global::$current_author_obj->ID;
//echo $td_author->ID;
//print_r($td_author);
$current_author_class = ”;
if (!empty(td_global::$current_author_obj->ID) and td_global::$current_author_obj->ID == $td_author->ID) {
$current_author_class = ‘ td-active’;
}
$buffy .= ‘<div class=”td_mod_wrap td-pb-padding-side’ . $current_author_class . ‘”>’;
$buffy .= ‘ID) . ‘”>’ . get_avatar($td_author->user_email, ’70’) . ‘‘;
$buffy .= ‘<div class=”item-details”>’;
$buffy .= ‘<div class=”td-authors-name”>’;
$buffy .= ‘ID) . ‘”>’ . $td_author->display_name . ‘‘;
$buffy .= ‘</div>’;
$buffy .= ‘<span class=”td-author-post-count”>’;
$buffy .= count_user_posts($td_author->ID). ‘ ‘ . __td(‘POSTS’, TD_THEME_NAME);
$buffy .= ‘</span>’;
$buffy .= ‘<span class=”td-author-comments-count”>’;
$comment_count = $wpdb->get_var($wpdb->prepare(“SELECT COUNT(*) AS total FROM $wpdb->comments WHERE comment_approved = 1 AND user_id = %d”, $td_author->ID));
$buffy .= $comment_count . ‘ ‘ . __td(‘COMMENTS’, TD_THEME_NAME);
$buffy .= ‘</span>’;
$buffy .= ‘<div class=”td-authors-url”>’;
$buffy .= ‘user_url . ‘”>’ . $td_author->user_url .’‘;
$buffy .= ‘</div>’;
$buffy .= ‘<div class=”post-name”>’;
$buffy .= get_the_author_meta(‘description’, $author_id);
$buffy .= ‘</div>’;
$buffy .= ‘</div>’;
}
}
$buffy .= ‘</div>’;
return $buffy;
}
}
hello, for our culture website we are building upon the newspaper theme and would like to do the following.
Certain types of posts, most importanly the posts in categories: live, camera eye and interview, have a large header image as set in the post template style as template number 6.
For instance see here: http://v2.enola.be/2018/03/28/bcuc/.
We would like to have that for these specific categories the template is always set as number 6.
Other posts in the categories film review, album review, don’t have large images attached and we don’t want the large header image as in template number 6 (it gets pretty ugly very fast), but for instance post template style nr. 12, which is missing the header image.
For instance see here: http://v2.enola.be/2018/02/27/us-girls-in-a-poem-unlimited/
For these posts in these categories we would like to see a fixed post template number 12.
So, instead of having to select it for each post with different category we would like to do it automatically, eliminating errors since we have quite a lot of users uploading content.
Is there a way to do this, for instance creating seperate single_template_6.php and loop-single-6.php files with a category slug, or won’t it work that way ?
kind regards for your insights on this.
Hi.
I understand that part of this customization might be not covered by your support, however, since I want just to remove a thing, I opened up this ticket.
Im using a big grid 6 shortcode, which uses td_module_mx5.php
If I edit this file and remove the division of the module class, first two images dissapear, however, they count on posts loop, so its the same just like hiding them via CSS.
Im searching of a way that will completely eliminate those two posts, having the other 5 there instead, starting from post 0.
Final Correction sorry, working outside the loop:
<?php
global $post;
get_the_category( $id );
if ( is_category($id) ) {
$current_category = single_cat_title("", false);
query_posts('category_name='.$current_category.'');
if (have_posts()) : while (have_posts()) : the_post();
if( get_the_tag_list() ){
echo '<div id="tagcloud"><h3>Popular Tags for '.$current_category.'</h3>';
echo $posttags = get_the_tag_list('
');
echo '</div>';
}
endwhile; endif;
wp_reset_query();
}
?>
-
This reply was modified 8 years by
acdmin.
Hi,
I’m trying to implement AdSense’s new InFeed ads on my post pages between the related posts.
Is there a way to add the do_shortcode with custom ad block containing the InFeed adcode somewhere between the code in td_block_related_posts.php? I’ve been looking into that piece of code but it looks like a loop and I don’t know where to add the shortcode to display the InFeed ad between related posts.
Any help would be greatly appreciated!
Dear,
I want to replace the related articles of the theme, with the Google AdSense ad “content for correspondence”. Google AdSense correspondence content: https://snag.gy/x2DGlb.jpg
Also I want to remove the block title “MORE FROM AUTHOR” and leave only the block title “RELATED ARTICLES”
I can make this change in two ways:
– One, I modify the td_block_related_posts.php core file and insert the AdSense code.
https://snag.gy/kX93ld.jpg – http://content.screencast.com/users/suport001/folders/Jing/media/143c4f6e-9bed-4af2-bef4-cb73930b5574/2015-09-09_1013.png
– Two, I insert the HTML code: <div class=”td_block_wrap td_block_related_posts”…<h4 class=”td-related-title”>… and AdSense code in the loop-single.php core file and I disable related articles from the theme panel? https://snag.gy/S8QzJE.jpg
Please, which of these two is the best way and does not create problems?
Of course I will use the child theme.
Thank you very much!
Regards,
Gabriel
$td_module = td_api_module::get_by_id($td_module_class);
if ($td_module[‘uses_columns’] === false) {
$td_template_layout->disable_output();
}
if (have_posts()) {
while ( have_posts() ) : the_post();
echo $td_template_layout->layout_open_element();
if (class_exists($td_module_class)) {
$td_mod = new $td_module_class($post);
echo $td_mod->render();
} else {
td_util::error(__FILE__, ‘Missing module: ‘ . $td_module_class);
}
echo $td_template_layout->layout_close_element();
$td_template_layout->layout_next();
$adcounter++;
if (is_home()) {
if ($adcounter == 4 or $adcounter == 8) {
echo do_shortcode(‘[td_ad_box spot_id=”custom_ad_2″]’);
}
}
endwhile; //end loop
echo $td_template_layout->close_all_tags();
Hi, i’m working with custom post types in ambrosia.com.br and with those inserts in functions.php it works fine for search, feed and main query, but i could not show the custom posts on Archive pages. Can you please help with this? Thanks in advance,
function add_post_types_to_loop_and_feed($query) {
if ($query->is_feed() || $query->is_main_query() && $query->is_front_page()) {
$query->set(‘post_type’, array(‘post’, ‘custom1’, ‘custom2’, ‘custom3’));
}
}
add_action(‘pre_get_posts’, ‘add_post_types_to_loop_and_feed’);
function searchAll( $query ) {
if ( $query->is_search ) {
$query->set( ‘post_type’, array( ‘post’, ‘page’, ‘feed’, ‘custom1’, ‘custom2’, ‘custom3’));
}
return $query;
}
add_filter( ‘the_search_query’, ‘searchAll’ );
Oh, this is too bad. I have exactly the same requirements: implementing a category-specific fallback featured-image for the posts where it is not added. While I was able to make the fallback featured image in the post view by following the instructions here, I’m struggling to have them displayed in the blocks and modules.
I have made changes to loop-single.php and this is what it looks like:
<?php if ( has_post_thumbnail() ) : ?>
<div class="entry-thumbnail">
"><?php echo $td_mod_single->get_image(td_global::$load_featured_img_from_template); ?>
</div>
<?php else :
$category = get_the_category();
?>
<div class="entry-thumbnail">
">/wp-content/uploads/category-images/<?php echo $category[0]->category_nicename ; ?>-741x486.jpg" alt="<?php the_title(); ?>" />
</div>
<?php endif; ?>
Is there no piece of code I can write somewhere that will replicate this result in modules?
Thanking you.
Im not aware of a way that this would be implemented.
Im looking to have different 728 banners in different categories.
At this time, there is no option to show an 728 within, or before, the posts loop of a category, but only a header one.
Please let me know about possible ways of implementing this (i.e. altering the php file to accept a shortcode and then adding the banner in a text box of a plugin that handles them)
Hello !
I saw it, so I started look in the theme in order to accomplish my will.
But I do not understand how you pass the category in the wp_posts loop, can you enlight me ?
Thanks 🙂
Hi,
That can be done in the posts loop settings (latest articles)
– https://www.screencast.com/t/2QefZvwoDdhH
– https://www.screencast.com/t/cXXUn5o9
There you can set the number of posts that will appear in the section.
Thanks
hi I have to implement an advanced search form. i have buy facetwp plugins but do not work because the class css called “facetwp-template” is missing.
I tried to insert it in the home page in the section “homepage latest articles”, “posts loop settings”, “extra class”.
When I add that CSS class, it’s not appearing on the front-end, so I don’t think that feature is working. Could you check the “Extra class” setting issue?
Hi, thanks for this info. I tried to add the codes in my “loop-single.php” and “loop-single-1.php” files, because I’m using the default template for my posts. However, it still displays the same. Please help. My website is: https://rachelrooi.com
<?php
/**
* The single post loop Default template
**/
if (have_posts()) {
the_post();
$td_mod_single = new td_module_single($post);
?>
<article id=”post-<?php echo $td_mod_single->post->ID;?>” class=”<?php echo join(‘ ‘, get_post_class());?>” <?php echo $td_mod_single->get_item_scope();?>>
<div class=”td-post-header”>
<?php echo $td_mod_single->get_category(); ?>
<header class=”td-post-title”>
<?php echo $td_mod_single->get_title();?>
<?php if (!empty($td_mod_single->td_post_theme_settings[‘td_subtitle’])) { ?>
<p class=”td-post-sub-title”><?php echo $td_mod_single->td_post_theme_settings[‘td_subtitle’];?></p>
<?php } ?>
<div class=”td-module-meta-info”>
<?php echo $td_mod_single->get_author();?>
<?php echo $td_mod_single->get_date(false);?>
<?php echo $td_mod_single->get_comments();?>
<?php echo $td_mod_single->get_views();?>
</div>
</header>
</div>
<?php echo $td_mod_single->get_social_sharing_top();?>
<div class=”td-post-content”>
<?php
// override the default featured image by the templates (single.php and home.php/index.php – blog loop)
if (!empty(td_global::$load_featured_img_from_template)) {
echo $td_mod_single->get_image(td_global::$load_featured_img_from_template);
} else {
echo $td_mod_single->get_image(‘td_696x0’);
}
?>
<?php echo $td_mod_single->get_content();?>
</div>
<footer>
<?php echo $td_mod_single->get_post_pagination();?>
<?php echo $td_mod_single->get_review();?>
<div class=”td-post-source-tags”>
<?php echo $td_mod_single->get_source_and_via();?>
<?php echo $td_mod_single->get_the_tags();?>
</div>
<?php echo $td_mod_single->get_social_sharing_bottom();?>
<?php echo $td_mod_single->get_next_prev_posts();?>
<?php echo $td_mod_single->get_author_box();?>
<?php echo $td_mod_single->get_item_scope_meta();?>
</footer>
</article> <!– /.post –>
<?php echo $td_mod_single->related_posts();?>
<?php
} else {
//no posts
echo td_page_generator::no_posts();
}
Hello,
The latest post loop will show all of the articles you have. You can limit the number shown on each page but not the whole number. This can only be done on individual blocks. The solution here would be not to use the page builder + latest articles section. Instead switch to the default template and create a block named latest articles and limit the pagination for it to the number of posts you want.
Thank you!
I feel rather stupid now!! Thank You so much. I put the ACF in the ‘loop-single2.php’ just below the content and it’s spot on! Thank you ever so much 🙂
May I ask… if the theme gets updated, would this template get overwritten? Should I create a new, specific template for my posts? The posts that need the ACF are in one, specific category.
Once again, thanks for your assistance! 🙂
lol ok , i know how to do it using loop.php, but is there any way to do it in category module. For example for category page i am using td_module_2.php
++ i just want to do it for parent category pages and not for sub categories. Any help will be really appreciable as i already wasted my hours and default category templates of newspaper look so weird
SubCat1 Post 1 Post 2
SubCat2 Post 1 Post 2
SubCat3 Post 1 Post 2
loop.php
` if(is_category()){
$categories = get_the_category();
$catID = $categories[0]->category_parent;
$subcats = get_categories(‘child_of=’ . $catID);
foreach($subcats as $subcat) {
echo ‘<h3>’ . $subcat->cat_name . ‘</h3>’;
echo ‘<ul>’;
$subcat_posts = get_posts(‘cat=’ . $subcat->cat_ID);
foreach($subcat_posts as $subcat_post) {
$postID = $subcat_post->ID;
echo ‘<li>’;
echo ‘<a href=”‘ . get_permalink($postID) . ‘”>’;
echo get_the_title($postID);
echo ‘</a></li>’;
}
echo ‘</ul>’;
}
}`
-
This reply was modified 8 years by
Mayank Kapahi.
-
This reply was modified 8 years by
Mayank Kapahi.
-
This reply was modified 8 years by
Mayank Kapahi.
Hi,
That is a post loop – https://codex.wordpress.org/The_Loop
It is used on category pages and Latest posts sections
– https://www.screencast.com/t/XOBhw3hd6g
If you know what you are doing you could make modifications to the loop. There could be online solutions as well.
As I said before, there are plans to add more functionality to the category pages in the future.
Thanks
I want to continue a grid past 3 articles. I want it to function similar to post loop.
What’s the best way to do this?
After exploring a bit I found the code for category page is coming from td_module.php and loop.php
if (have_posts()) {
while ( have_posts() ) : the_post();
echo $td_template_layout->layout_open_element();
if (class_exists($td_module_class)) {
$td_mod = new $td_module_class($post);
echo $td_mod->render();
} else {
td_util::error(__FILE__, ‘Missing module: ‘ . $td_module_class);
}
echo $td_template_layout->layout_close_element();
$td_template_layout->layout_next();
endwhile; //end loop
echo $td_template_layout->close_all_tags();
Can you please provide any help in showing category page by order of subcategories seperately. Example
Category page:
Category Name
Subcategory Name 1- Posts of 1
Subcategory Name 2- Posts of 2
Subcategory Name 3- Posts of 3
And can you please tell where is a query for fetching categories and there posts?
http://qc.round.glass/blossom/category/make-them-eat-eat-n-grow/
-
This reply was modified 8 years by
Mayank Kapahi.
Hello Guys,
I’ve tried to add this code in thr single loop post but it’s not showing on mobile
<?php echo do_shortcode (‘[vc_row][vc_column width="2/3"][td_block_21 custom_title=”Latest Articles” block_template_id=”” sort=”random_posts” ajax_pagination=”load_more” tdc_css=”eyJhbGwiOnsiYm9yZGVyLXN0eWxlIjoibm9uZSJ9fQ==”][/vc_column][vc_column width="1/3"][/vc_column][/vc_row][vc_row][vc_column][/vc_column][/vc_row]‘); ?>
here is the file that works perfectly – if you do not use buddypress.
<?php
/* —————————————————————————-
the default page template
*/
get_header();
//set the template id, used to get the template specific settings
$template_id = ‘page’;
$loop_sidebar_position = td_util::get_option(‘tds_’ . $template_id . ‘_sidebar_pos’); //sidebar right is default (empty)
//get theme panel variable for page comments side wide
$td_enable_or_disable_page_comments = td_util::get_option(‘tds_disable_comments_pages’);
//read the custom single post settings – this setting overids all of them
$td_page = td_util::get_post_meta_array($post->ID, ‘td_page’);
if (!empty($td_page[‘td_sidebar_position’])) {
$loop_sidebar_position = $td_page[‘td_sidebar_position’];
}
// sidebar position used to align the breadcrumb on sidebar left + sidebar first on mobile issue
$td_sidebar_position = ”;
if($loop_sidebar_position == ‘sidebar_left’) {
$td_sidebar_position = ‘td-sidebar-left’;
}
/**
* detect the page builder
*/
$td_use_page_builder = td_global::is_page_builder_content();
if ($td_use_page_builder) {
// the page is rendered using the page builder template (no sidebars)
if (have_posts()) { ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class=”td-main-content-wrap td-main-page-wrap td-container-wrap”>
<div class=”<?php if (!td_util::tdc_is_installed()) { echo ‘td-container ‘; } ?>tdc-content-wrap”>
<?php the_content(); ?>
</div>
<?php
if($td_enable_or_disable_page_comments == ‘show_comments’) {
?>
<div class=”td-container”>
<div class=”td-pb-row”>
<div class=”td-pb-span12″>
<?php comments_template(”, true); ?>
</div>
</div>
</div>
<?php
}
?>
</div> <!– /.td-main-content-wrap –>
<?php endwhile; ?>
<?php }
} else {
//no page builder detected, we load a default page template with sidebar / no sidebar
?>
<div class=”td-main-content-wrap td-container-wrap”>
<div class=”td-container tdc-content-wrap <?php echo $td_sidebar_position; ?>”>
<div class=”td-crumb-container”>
<?php echo td_page_generator::get_page_breadcrumbs(get_the_title()); ?>
</div>
<div class=”td-pb-row”>
<?php
switch ($loop_sidebar_position) {
default:
?>
<div class=”td-pb-span8 td-main-content” role=”main”>
<div class=”td-ss-main-content”>
<?php
if (have_posts()) {
while ( have_posts() ) : the_post();
?>
<div class=”td-page-header”>
<h1 class=”entry-title td-page-title”>
<span><?php the_title() ?></span>
</h1>
</div>
<div class=”td-page-content”>
<?php
the_content();
endwhile;//end loop
}
?>
</div>
<?php
if($td_enable_or_disable_page_comments == ‘show_comments’) {
comments_template(”, true);
}?>
</div>
</div>
<div class=”td-pb-span4 td-main-sidebar” role=”complementary”>
<div class=”td-ss-main-sidebar”>
<?php get_sidebar(); ?>
</div>
</div>
<?php
break;
case ‘sidebar_left’:
?>
<div class=”td-pb-span8 td-main-content <?php echo $td_sidebar_position; ?>-content” role=”main”>
<div class=”td-ss-main-content”>
<?php
if (have_posts()) {
while ( have_posts() ) : the_post();
?>
<div class=”td-page-header”>
<h1 class=”entry-title td-page-title”>
<span><?php the_title() ?></span>
</h1>
</div>
<div class=”td-page-content”>
<?php
the_content();
endwhile; //end loop
}
?>
</div>
<?php
if($td_enable_or_disable_page_comments == ‘show_comments’) {
comments_template(”, true);
}?>
</div>
</div>
<div class=”td-pb-span4 td-main-sidebar” role=”complementary”>
<div class=”td-ss-main-sidebar”>
<?php get_sidebar(); ?>
</div>
</div>
<?php
break;
case ‘no_sidebar’:
?>
<div class=”td-pb-span12 td-main-content” role=”main”>
<?php
if (have_posts()) {
while ( have_posts() ) : the_post();
?>
<div class=”td-page-header”>
<h1 class=”entry-title td-page-title”>
<span><?php the_title() ?></span>
</h1>
</div>
<div class=”td-page-content”>
<?php
the_content();
endwhile; //end loop
}
?>
</div>
<?php
if($td_enable_or_disable_page_comments == ‘show_comments’) {
comments_template(”, true);
}?>
</div>
<?php
break;
}
?>
</div> <!– /.td-pb-row –>
</div> <!– /.td-container –>
</div> <!– /.td-main-content-wrap –>
<?php
}
get_footer();
Hi,
The top grid will display three posts from the Featured category, unless changing the value as shown. The section below will display posts sorted by Latest. The post will be displayed in the latest post loop, depending on post publish date.
Thanks