- NewsmagPage templates
Hello,
I have a website that the products only show 4 results per product archives. I’ve tried modifying the functions.php file to bring more products in a loop, but it does nothing.
// Number of product per page 8
add_filter(‘loop_shop_per_page’, create_function(‘$cols’, ‘return 12;’));
if (!function_exists(‘woocommerce_output_related_products’)) {
// Number of related products
function woocommerce_output_related_products() {
woocommerce_related_products(array(
‘posts_per_page’ => 12,
‘columns’ => 4,
‘orderby’ => ‘rand’,
)); // Display 4 products in rows of 1
}
}
Thanks
I’m trying to only display certain tags in the loop so I’m using this:
<?php function custom_tags( $query ) {
if (is_admin()){
$query->is_main_query();
return;
}
$query->set( 'tag', "food, recipes, kitchen" );
}
add_action( 'pre_get_posts', 'custom_tags' );
It has been working fine, but I notice this bit of code here makes the whole menu disappear:
$query->set( 'tag', "food, recipes, kitchen" );
How do I stop it from affecting the menu of my wordpress site?
Currently I’m using this code:
function exclude_cat( $query ) {
$query->set( 'cat', '-58' );
}
add_action( 'pre_get_posts', 'exclude_cat', 1 );
and it works perfectly fine to exclude the posts from my site, but it also excludes it from the “All Posts” section to where I can no longer see it.
How do I exclude this category from the website but have it still visible in the backend?
Hi,
I have replied you on themeforest’s dashboard on this. I have pasted my replies and our conversation below, hope you don’t mind.
I would use the block 16 as module , it is possible ? And if so, how can I do ?
tagDiv
Hi,
Unfortunately not without customization, as blocks’s template uses additional customizations to display 3/5 posts on 2/3 columns so setting/using that as module woudl display one post on each column resulting in a similar layout like this: http://demo.tagdiv.com/newsmag/block-3/
I’ll add this on our request list and consider it for future theme updates.
Thanks for the message!
Lucian C. tagDiv
I would like to customize , you could point me in which I would have to edit files.
tagDiv
Hi,
Sure, you can find the block’s 16 template file to see theme’s implementation for it here: http://screencast.com/t/0GNsavDbKxi then, for category’s modules layout in the loop.php file: http://screencast.com/t/X4kdqTz2Xoc
You would have to create a case in the loop file for your case. Please also note that we cannot provide customization services at the moment so if you can’t manage this on your own we advise you to get in touch with a freelancer or someone that could help you and also make sure you backup these files before customizing them.
Hope this helps!
Thanks for the message! Lucian C. tagDiv
Thanks!
Hello,
The code for single posts is found in the main theme folder: http://screencast.com/t/zOn5h097nyc4 Every template has 2 files to it. The single and the loop-single. So single.php and loop-single.php would be the files for the default template, single 1 and loop-single 1 for post template 1…etc.
I hope this helps.
Thank you!
Hi
For posts displayed in blocks you have to edit the td_data_source.php file http://screencast.com/t/wjLPyZxqrI If you want to alter the category page for example or any other page which use the loop.php file, you need to add your customizations in functions.php file. Fore more details about the posts query check this link: https://codex.wordpress.org/Function_Reference/query_posts
Please consider that this is a complex task which require good coding skills and if you’re not aware of the steps you need to take in this regard please consider hiring a developer or a freelancer to do this for you as we can’t offer any type of custom work at the moment.
Thanks!
What I’m trying to do is alter the loop across my site so it will check the site URL so it will know which content to display based on tag.
For example, if I give some posts the tag “golfclubs”, I want it to work something like this:
if ($_SERVER['HTTP_HOST']=="www.golfclubreviewdomain.com"){
// code here to display only the "golfclubs" tagged posts within the loop
}
And my final question, what change do I make to display more than 1 type of tagged post? maybe something like “golfclubs” and “general”?
Where would I place this code to make the changes to every loop across my site?
Awesome thank you.
I’d like to change it up a little and only show an ad every 6 posts. Where can I set the adcounter to zero to have it loop properly for module 16?
Hello rishab55555
Below, I gave you an example for what you want to achieve to put a button after the posts title. First of all, you need to make a custom class and add an image button you like and place it in loop_single.php, like this: http://screencast.com/t/FapsZDElh and also the code you should find here: http://pastebin.com/iHh4SKpy . After this changes, you have to use a bit of Css with the code below:
.button {
position: relative;
float: left;
display: block;
top: 9px;
padding-right: 10px;
}
The result you should see here: http://screencast.com/t/9uofVar07nx
There is just an example. You can adjust the values and put another image source until you get what you want.
If you want to have another different button for each post title, please find a plugin to do this for you.
Hope this helps!
Thank you for the message!
I deleted all of the “loop” files from FTP and re-uploaded new ones from the re-downloaded theme. Nothing…
The liip.php file that I’ve got:
<?php
/**
* If you are looking for the loop that's handling the single post page (single.php), check out loop-single.php
**/
// $global_flag_to_hide_no_post_to_display - comes from page-category-big-grid.php and is a flag to hide the 'No posts to display' message if on category page there are between 1 and 5 posts
global $loop_module_id, $loop_sidebar_position, $global_flag_to_hide_no_post_to_display;
///if we are in wordpress loop; used by quotes in blocks to check if the blocks are displayed in blocks or in loop
td_global::$is_wordpress_loop = true;
$td_template_layout = new td_template_layout($loop_sidebar_position);
if (empty($loop_module_id)) { //not sure if we need a default here
$loop_module_id = 1;
}
$td_module_class = td_api_module::_helper_get_module_class_from_loop_id($loop_module_id);
//disable the grid for some of the modules
$td_module_api = td_api_module::get_by_id($td_module_class);
if ($td_module_api['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();
endwhile; //end loop
echo $td_template_layout->close_all_tags();
} else {
/**
* no posts to display. This function generates the __td('No posts to display').
* the text can be overwritten by the themplate using the global @see td_global::$custom_no_posts_message
*/
echo td_page_generator::no_posts();
}
Hello,
1) Please make sure the ads are not disabled on tablets from here: http://screencast.com/t/42JqjI7wfymi
2) you will need to edit the theme file corresponding to the template you use in your posts: http://screencast.com/t/8jidV29LLAyb The default post template uses loop-single, template one is loo-single 1 and so on. http://screencast.com/t/PFrzK5oAdjL
Thank you!
Hi,
The latest articles is controlled from the loop settings below the main content window: http://screencast.com/t/QKvWu04nGzp . Adjust the settings here to limit posts and remove pagination.
Thank you!
Hello,
I see you used visual composer on posts. You can change the post template if you wish from the post settings.
You are placing the ad in visual composer inside the content. You cannot move it above the content from the files if you use it like this. What you can do is edit the default template (i assume that one is specified in the panel) and add your visual composer shortcode to the file: http://screencast.com/t/dRb58PAz4
code: <?php echo do_shortcode('[td_block_ad_box spot_id="custom_ad_2"]')?>
And then remove the ad box from your post as it will be picked up from the code you insert.
This will make every post that has the default template specified display the ad.
I hope this helps. If the default template is not specified in the panel you can apply the customization to the other loo-single files depending on the template specified. loop-single is the default template, loop-single-1 is template 1, so on and so forth.
Thank you!
Hello,
Unfortunately there is no option for this in the theme but it can be done with a bit of customization.
You can hide the other review scores with css in order to just display the overall score:
before: http://screencast.com/t/j0lEQc3x
after: http://screencast.com/t/zH23QN8DuqG2
Use this code in the theme panel->custom css box:
.td-review-row-stars{
display:none!important;
}
As for the position you will nedd to edit the theme files to move the reviews.
Edit the loop-single_x.php template you use on your post. (you will need to edit every template you use on your posts http://screencast.com/t/gNewwrcmEQ3q)
Modify the template you use like so: http://screencast.com/t/CcMkeJjJ
Thank you!
Hi Lucian, the old post is not quite clear on the method, you mention css and I can’t tell if that is an additional fix for something else or for the date etc.
Could you please repost the exact code to remove the date and in what file please.
Also what about this method?
1. Using Code in Functions File
This can be considered as the aggressive version of removing date and time-stamp from your WordPress blog. It is very powerful and removes the function of every php code, that helps to generate date. Date displayed in the comments will also be completely removed.
/** Start of Remove Date TimeStamp from blog posts */
function remove_post_dates() {
add_filter('the_time', '__return_false');
add_filter('get_the_time', '__return_false');
add_filter('the_modified_time', '__return_false');
add_filter('get_the_modified_time', '__return_false');
add_filter('the_date', '__return_false');
add_filter('get_the_date', '__return_false');
add_filter('the_modified_date', '__return_false');
add_filter('get_the_modified_date', '__return_false');
add_filter('get_comment_date', '__return_false');
add_filter('get_comment_time', '__return_false');
}
add_action('loop_start', 'remove_post_dates');
/** End of Remove Date TimeStamp from blog posts */
Add this code to functions.php file in your theme and update it. Wait for Google Search Bots to crawl and index your blog posts. Date will be removed from meta description of search results.
—
I read this article How to Remove Date From Google Search Results
It’s a better idea to remove dates from last year content, and for all latest content (ex: 2013 posts), let the date remain intact.
Note: I don’t recommend hiding date, rather show last updated time.
This is getting confusing…. Many sites say don’t hide it, some say don’t delete it and leave space, google hates space…too confusing….
I guess I’ll leave it in, there’s a reason why it’s coded in, maybe i shouldn’t mess with it and hope google doesn’t punish bloggers for having a date in their snippet.
-
This reply was modified 10 years by
mboydnv.
Hello,
The image number is for the image i set. I showed you above how to use a single image element in visual composer. Just create a blank page, add a single image element, select your image, apply some settings/styling to it, then enter classic mode and text mode(not visual) and you will see the code for your image.
You can use the same method on posts. The posts have 2 files that correspond for one template. There is the single.php files and the loop-single.php. For this you have to edit the loop files. http://screencast.com/t/Dq6GqnpUBQ3O
Thanks.
Hi,
I am using Newspaper 6 Theme.
On category pages we have filter passed in query string which is post tag. So want to filter my posts according to that query string tag.
So I have changed query successfully which is effecting results of main category pages content. On loop.php modifying query with post tag make desired results. (In child theme)
But when it comes to top grid, it is hard-cord value of 5 passed there and if posts with tag are not present it displays nothing.
I found this piece of code which is calling Top grid :
<?php td_api_category_template::_helper_show_category_template() ?>
<?php td_api_category_top_posts_style::_helper_show_category_top_posts_style() ?>
And there is main function in File: /Newspaper/includes/wp_booster/td_wp_booster_functions.php
/* ----------------------------------------------------------------------------
* modify the main query for category pages
*/
add_action('pre_get_posts', 'td_modify_main_query_for_category_page');
function td_modify_main_query_for_category_page($query) {
//checking for category page and main query
if(!is_admin() and is_category() and $query->is_main_query()) {
//get the number of page where on
$paged = get_query_var('paged');
//get the filter_by
URL($_GET) variable
$filter_by = get_query_var('filter_by');
<strong> $query_tag = filter_input( INPUT_GET, 'tag', FILTER_DEFAULT );
if($query_tag)
$query->set('tag',$query_tag); /*<strong>I tried modifying query but it does not effect top posts*/</strong>
//get the limit of posts on the category page
$limit = get_option('posts_per_page');
// get the category object - with or without permalinks
if (empty($query->query_vars['cat'])) {
td_global::$current_category_obj = get_category_by_path(get_query_var('category_name'), false); // when we have permalinks, we have to get the category object like this.
} else {
td_global::$current_category_obj = get_category($query->query_vars['cat']);
}
//offset is hardcoded because of big grid
$offset = td_api_category_top_posts_style::_helper_get_posts_shown_in_the_loop();
//echo $filter_by;
switch ($filter_by) {
case 'featured':
//get the category object
$query->set('category_name', td_global::$current_category_obj->slug);
$query->set('cat', get_cat_ID(TD_FEATURED_CAT)); //add the fetured cat
break;
case 'popular':
$query->set('meta_key', td_page_views::$post_view_counter_key);
$query->set('orderby', 'meta_value_num');
$query->set('order', 'DESC');
break;
case 'popular7':
$query->set('meta_key', td_page_views::$post_view_counter_7_day_total);
$query->set('orderby', 'meta_value_num');
$query->set('order', 'DESC');
break;
case 'review_high':
$query->set('meta_key', td_review::$td_review_key);
$query->set('orderby', 'meta_value_num');
$query->set('order', 'DESC');
break;
case 'random_posts':
$query->set('orderby', 'rand');
break;
}//end switch
// offset + custom pagination - if we have offset, WordPress overwrites the pagination and works with offset + limit
if(empty($query->is_feed)) {
if ( ! empty( $offset ) and $paged > 1 ) {
$query->set( 'offset', $offset + ( ( $paged - 1 ) * $limit ) );
} else {
$query->set( 'offset', $offset );
}
}
}//end if main query
}
While using Grid style one:
includes/shortcodes/td_block_big_grid_1.php
POST_LIMIT is passed as 5.
So is there any way that my category posts get filter by tag for top grid as well. I tried modifying main function as mentioned above. Please see this comment in code above (I tried modifying query but it does not effect top posts)
Please suggest how that will be possible.
Screen shot attached for details of URL having query string:
Hi
Your code is missing the loop part which check if there are any post to be displayed on the page. A basic loop example it’s in this code:
<?php if ( have_posts() ) ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="td-container"> //the theme uses this classes for
<div class="td-container-border"> //post/page content
<?php the_content(); ?>
//you can place a custom code here, depending by your needs
</div>
</div>
<?php endwhile; ?>
The theme display the page content using this classes: td-container, td-container-border You can replace them if you want but in this case you need to create your own css for layout. Also you can use your classes within theme’s classes like this:
<div class="td-container"> //the theme uses this classes for
<div class="td-container-border"> //post/page content
<div class="img-header-home">
<div class="container mt-130 z-index100">
My static content
<?php the_content(); ?>
//you can place a custom code here, depending by your needs
</div>
</div>
</div>
</div>
You can check this example code here: http://pastebin.com/8E0XZ8de which produce this result: http://screencast.com/t/p8SsR9P2x9W – http://screencast.com/t/N95ikdPhHY
This is a basic example, but you can customize your page template as you need by ading different conditions in that file. For more information regarding WordPress loops you can check the official documentation: https://developer.wordpress.org/themes/basics/the-loop/
Hope this help.
Thanks!
-
This reply was modified 10 years by
Andrei L..
Hello.
I need to remove into home page the post loops. I have tried to set Limit post number to 0, but it doesn’t work.
Could you help me?
Regards.
Hello,
I have newspaper theme v6.5 installed on my website.
URL – http://www.naukrinama.com
I wanted to put a static social media sharing options and whatsapp sharing link below each of my posts automatically. I figured out that I need to make changes to loop-single.php file.
I have placed my code below the line which calls the function get_content() and it displays it at the position as shown in the screenshot below. I want my data to come exactly after the post description. Currently it is coming below the social icons and advertisement.
With further research i found that i have to make changes to the file where get_content() function is defined in theme. Can you please let me know where can i edit it, or how can i achieve the desired result as shown in the screenshot below.
Staging Implementation URL – http://hackaholicit.com/naukrinama/upsc-released-senior-public-prosecutor-seniority-list-cbi-results-1/
Screenshot – http://imgur.com/iNpfkrE
Hello,
Unfortunately the theme does not have an option for it, so you have to use the code method. You can use a ‘do_shortcode’ function: <?php echo do_shortcode('your shortcode here');?> and place it in the post template you use on your post (loop_single.php if it is the default one)
Every post template has a file to go with it. The default is without a number to it. The others correspond to their post template number.
You can add for example a trending now block in posts by editing the file template corresponding with the post template used, and add this line of code like here: http://screencast.com/t/Jf5SKCFx5Pka – http://screencast.com/t/7j8xHNyc6
<?php echo do_shortcode('[vc_row][vc_column][td_block_trending_now][/vc_column][/vc_row]'); ?>
As for the ads, the theme uses adsense code and every other custom ones have to be done by using this method here: https://forum.tagdiv.com/using-other-ads/
I hope this helps
Thanks!
-
This reply was modified 10 years by
Bogdan B..
Hi
I suspect you’re using page builder + latest articles as page template in Visual Composer: http://screencast.com/t/eRU4fCDo You can find more informations about page templates in our documentation: https://forum.tagdiv.com/page-templates-2/ Also you can change the sidebar from page settings: http://screencast.com/t/7y3bwpnv2J and you can customize the latest article area from posts loop settings: http://screencast.com/t/IIpzqFa7hQ7 Regarding the sidebar widget that can be customized from Appearance > Widgets: http://screencast.com/t/UH5kUA4Dp IOn this section you can add or remove elements from that widged or change the blocks settings displayed in the widget.
Hope this help.
Thanks!
Hello Bintmusic,
In order to move related articles to sidebar, you have to modify the core files of the theme.
The theme uses loop-single-x.php and single_template_x.php where x is the post template number you chose in your post settings. Loop-single.php and single.php (no numbers) are the files for the default template.
Depending on what post template you use, you must make this modification in multiple files.
First of all you need to remove related articles from posts. This does not work if you remove it from the theme panel because it will remove your sidebar ones as well. Just comment out or remove this code from the ‘loop’ files: <?php echo $td_mod_single->related_posts();?> from the specific loop-single-(number).php – http://screencast.com/t/G3zz9D22f
And simply place it in the ‘single’ files under the sidebar: http://screencast.com/t/J5lBN4ypghKc
The result: http://screencast.com/t/VX1hdnJO
Thank you
Was reading in another thread about using fb comments plugin: https://wordpress.org/plugins/facebook-comments-plugin/
but I’d like to move the location of where the fb comments appear to directly below the article. The plugin allows for the shortcode [fbcomments]
You can also insert the comment box as a shortcode into any post, page or template and use your own settings for each time you do it! Simply use the shortcode [fbcomments]
however when I try to add it to loop-single-5.php for example, it just prints the words [fbcomments] where I want the comments to appear. Do I need to add it to single_template_1.php?
http://screencast.com/t/9uoWD9tIXeP
Is there a better way to directly add fb comments to newspaper? If I generate the code on https://developers.facebook.com/docs/plugins/comments#configurator it gives me the facebook sdk to add to “ideally right after the opening <body> tag.” and then add
<div class="fb-comments" data-href="http://developers.facebook.com/docs/plugins/comments/" data-width="100%" data-numposts="5"></div>
Thanks!
You can try to add your coding to the style template found in your /themes/Newspaper/ folder. Note there are different templates for each post style, like “style5” and then a loop file for “style5” which has the content loop. Usually when I go to move/insert stuff I will open up the file, and put in something like
<p>testing placement</p>
into a spot, then upload then go to the website to look at one of the posts.
I’m sure tagdiv will provide a better step by step, but that’s the broad strokes on how to do it. 🙂