Search Results for 'posts loop'

Results from the Forum
vzey
Participant
#0

Hi there

I am using the Peadig Facebook comments plugin and have disabled the built in comments and the default facebook comments for posts and have put in this code to loop-single.pgp

<footer>
<?php echo $td_mod_single->get_post_pagination();?>
<?php echo $td_mod_single->get_review();?>

<div class="td-post-source-tags td-pb-padding-side">
<?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 do_shortcode('[fbcomments]'); ?>
<?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>

I want to add padding on the left, where/how to do it?

View post on imgur.com

<script async src=”//s.imgur.com/min/embed.js” charset=”utf-8″></script>
Thanks

jonnybalfour
tagDiv Member

Eh thats very strange, its showing on all posts for me?

Do i need to add this code to all loop.single.php?

Thanks

sylcharlestone
tagDiv Member

Hi Andrei,

Thanks much for your answer, you’re very nice to answer so quickly.

A) I tried and it works, thanks!. Now if I have several posts to hide.. how does it work? Like this?
‘if (is_single(134,7888,0967,12,34)’ .. just with a comma?

B) I tried to change only on loop-single-1.php but it didn’t work. Do I need to change from
loop-single.php to loop-single-13.php, all of them (that is 14 elements to change)? Or just loop-single-1.php?

Thanks?

John

broadstone
tagDiv Member

Also, I find myself confused by the way the system woks for setting up pages and which posts are displayed on which pages.

I want to be able to select a couple of categories to have as navigation links and have them look the same as the Homepage. I created a category “P2P” and figured out how to add as a nav link, but I can’t make it look like the Home Page (Homepage-Loop). Can you tell me how to do this?

Also how to I control which posts show on the other Pages I created (example Investing page)

Thanks

Alin [tagDiv]
tagDiv Staff

Hi,

The articles ads are placed in the content(get_content function), and the function is defined here – http://screencast.com/t/VQCmUU7Y This function is used in post templates – http://screencast.com/t/8EyWM8dCb
You can add a condition to block them on a specific post using is_single() function, check this topic as reference – https://forum.tagdiv.com/topic/disable-ads-on-particular-posts/
If you want to remove all the ads from your post(including header), you can try to add a condition like this(just add you post ID) – http://screencast.com/t/Yo7c5lffhOfN

if(!is_single('ID'))

You can read more about is_single function here – https://codex.wordpress.org/Function_Reference/is_single

To create a post template, please take a look at theme templates(loop and single) and use that structure, please check the official documentation – https://codex.wordpress.org/Post_Types#Custom_Post_Type_Templates

Thanks!

Afterglow
tagDiv Member

Hi,

Go to all pages, find your homepage and edit it. Find Homepgae latest articles and click on the 2nd tab Posts loop settings. Locate Limit post number and input the desired number of articles to appear…

Regards,
Peter

redwolfgirl66
tagDiv Member

Hello,

I added the code to the loop-single.php file and it appears to be working but only on the posts that use the video format but not on standard posts. Which template file is used for standard posts?

Thanks!

Victoria

gedlingeye
Participant
#0

Hi,

I think it’s called that!! At the bottom of my page content continue sto gon on for ever. I tried to stop this by filtering out the search. Now it always says ‘no posts to display’ at the bottom of my page all the time..

I am happy with the catagories in blocks I have selected on the homepage. I do I stop other content from looping below continuously. I did fix it by accident befor update to Newspaper 6, but can’t remember

Bryson T
Participant
#0

An obvious way to do this is to simply use Big Grid 4 multiple times as needed and let infinite load handle the rest, but my concern is that doing so will result in far too many queries running something like a dozen loops on the initial load of the home page.

So my questions are:

  1. With big grid 4 loading 2 posts per instance, how insane would page load and server load be if I used that grid for 24+ posts on the home page?
  2. How would I go about either altering big grid 4 to display more than 2 posts per instance, or create a new big grid that uses grid styles, looks like big grid 4, and accepts a post count parameter?

I assume #2 can be done via the Theme API but the documentation isn’t clear on grids, only blocks and modules. I definitely want something that can be protected through updates without a child theme, but a couple of edits per update is fine too. This is still slightly experimental but big grid 4 with grid style #4 looks amazing and shows a lot of promise, so I’m willing to commit to a fair bit of work to make this happen. I need some advice on getting started though.

Thanks.

fusion
tagDiv Member

I have used block 16 in single loop .php to display other posts from the same category.
Please how to change th query that display block 16 to ecxlude the actual post from displaying
http://www.panorama.com.al/basha-instat-i-qeveritar-pranoi-sot-zyrtarisht-krizen-rama/

I want in the right hand of website not to show the actual post but others from the same category
Where to find this $buffy .= $this->inner($this->td_query->posts, $td_column_number); to modify?
I use this shortcode in loop_single1
<?php echo do_shortcode(‘[td_block_16 limit=”5″ style=”” category_id=”‘.$rezi.'” category_ids=”” tag_slug=”” autors_id=”” installed_post_types=”” sort=”” limit=”5″ offset=”1″]’);?>

$rezi is post category but i want to exclude thispostid

Alin [tagDiv]
tagDiv Staff

Hi,

Those templates that come with the theme were created for posts, they will not work with custom post type. For custom post type you have to create a template, you can use structure present in the post template 8. Just check the code structure inside the template files single_template_8.php and loop-single-8.php and check the official documentation – https://codex.wordpress.org/Post_Types#Custom_Post_Type_Templates

Thanks!

aleister
tagDiv Member

This is the error I get:

Parse error: syntax error, unexpected 'and' (T_LOGICAL_AND) in /home/sitename/public_html/wp-content/themes/Newsmag/includes/wp_booster/td_wp_booster_functions.php on line 1656

and the code I use is

/* —————————————————————————-
* 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()) and (is_front_page() and is_home() )){

// 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’]);
}

// we are on a category page with an ID that doesn’t exists – wp will show a 404 and we do nothing
if (is_null(td_global::$current_category_obj)) {
return;
}

//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');

//get the limit of posts on the category page
$limit = get_option('posts_per_page');

//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

// how many posts are we showing in the big grid for this category
$offset = 5;

// 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 );
}
}
//print_r($query);
}//end if main query
} `

it was

/* ----------------------------------------------------------------------------
* 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 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']);
}

// we are on a category page with an ID that doesn't exists - wp will show a 404 and we do nothing
if (is_null(td_global::$current_category_obj)) {
return;
}

//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');

//get the limit of posts on the category page
$limit = get_option('posts_per_page');

//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

// how many posts are we showing in the big grid for this category
$offset = td_api_category_top_posts_style::_helper_get_posts_shown_in_the_loop();

// 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 );
}
}
//print_r($query);
}//end if main query
}`

I believe this part is the error


<code>        // how many posts are we showing in the big grid for this category
        $offset = td_api_category_top_posts_style::_helper_get_posts_shown_in_the_loop();

Any directions would be very welcome,
Site is http://www.technopat.net

Thank you

  • This reply was modified 10 years by aleister.
  • This reply was modified 10 years by aleister.
willbarnes
Participant
#0

Added this function: (which works almost all the time)
function catch_that_image() {
global $post, $posts;
$first_img = ”;
ob_start();
ob_end_clean();
$output = preg_match_all(‘/<img.+src=[\'”]([^\'”]+)[\'”].*>/i’, $post->post_content, $matches);
$first_img = $matches[1][0];

if(empty($first_img)) {
$first_img = “/path/to/default.png”;
}
return $first_img;
}

And Added this to various loops, but still didn’t work:

if ( get_the_post_thumbnail($post_id) != ” ) {

echo ‘‘;
the_post_thumbnail();
echo ‘
‘;

} else {

echo ‘‘;
echo ‘<img src=”‘;
echo catch_that_image();
echo ‘” alt=”” />’;
echo ‘
‘;

}

The Independent
tagDiv Member

Still no luck.

Here’s the error…

Parse error: syntax error, unexpected $end in /home2/independ/public_html/wp-content/themes/Newspaper/loop-single-7.php on line 43

And here are the blocks of text as they exist now…

<div class=”td-pb-span8 td-main-content <?php echo $td_sidebar_position; ?>-content” role=”main”>
<div class=”td-ss-main-content”>
<?php
locate_template(‘loop-single-7.php’, 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”>
<div class=”td-ss-main-content”>
<?php
locate_template(‘loop-single-7.php’, true);

?>

</div>

<?php comments_template(“, true);?>
<?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>

TheMediumUTM
tagDiv Member

This is part of the single template code, found in single_template_#.php and the corresponding loop-single-##.php in the Newspaper theme folder.

single_template_## loads loop-single-##, which has this block:


<?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();?>

and single_template_## also has, immediately after loading single-loop-##, this:


comments_template('', true);

Swapping those various lines around would do the trick.

The two robust ways to do this update are via a child theme or via the new theme API.

The theme API is a simple plugin that adds your custom templates, modules, blocks, etc. to the theme panel. I just switched most of my modifications that were in a child theme to the theme API, since child themes come with other complications and potential slowdowns.

https://forum.tagdiv.com/the-theme-api/

In this case, you would (1) create a plugin folder, (2) find the template(s) you want to make this change in and copy both the loop-single-## and single_template_## files for those templates into your plugin folder, (3) edit them to swap the order of those elements, (4) add the code to register them in the main plugin file, and (5) upload and activate the plugin in your dashboard and switch your post templates in the theme panel.

If you wanted to do this via child theme instead, it would be less work but not quite as “robust”, at least in the opinion of some.

https://forum.tagdiv.com/the-child-theme-support-tutorial/

This time you would simply make your child theme as per that tutorial, copy the single templates in there, and edit and upload them and they would invisibly replace the ones that come with the theme.

P.S. Because that comment template code loading is in single_template_##, moving it to loop-single-## might work oddly. Or it might be fine. Haven’t tried it myself.

SaL
Participant
#0

Hey again.

Loving the theme.

I am messing around with the custom page builder now and noticed that I can’t exclude posts from blocks that have a certain tag. I am curious if there is a way to remove all “Expired” tagged posts from homepage custom page builder blocks.

Would I have to edit each block template or is there some sort of loop before the template?

Any help be great,

Thanks for all the support, <3

Alin [tagDiv]
tagDiv Staff

Hi,

Unfortunately the theme doesn’t have an option to place an ad(or more) on category page from Theme Panel, but we will consider this when a new ad system will be created.
You can place ads in category page using do_shortcode function if you want, just edit the loop.php file and follow this solutions:
https://forum.tagdiv.com/topic/how-can-add-horizontal-sidebar/#post-62563 – using this solution you can place ads after x posts
https://forum.tagdiv.com/topic/custom-ads-4/#post-62511 – you can add the ad after each post

Thanks!

simchris
tagDiv Member

Typically you would edit the template you’re using for your posts, like template 4 or whatever. There are two templates in the theme root, one for the loop, one for the layout, for each template type. So, you can usually test this by opening one of them and putting some text like TEST TEXT HERE in a div, then look at that online to see where it shows up.

Emil G
tagDiv Staff

Hi,

You have to add it inside the loop.php file – http://screencast.com/t/6YLFcO3Vhttp://screencast.com/t/LfA5kbiMNG3C
To make it display only on category pages or only after 2 or 3 posts you have to create conditions. If you don’t know how i suggest that you look for a professional developer to help you with this task.

echo td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'custom_ad_1'));

Thank you!

  • This reply was modified 11 years by Emil G.
mpindado
Participant
#0

Hi, I have just updated to newsmag 2.1 and my CPT posts stopped working.

I see several issues:

– Now there is a “From panel” post template. What is this exactly?

– In previous versions, I set the template (e.g. single_template_3) for my CPT, setting meta key
td_post_theme_settings[“td_post_template”] = “single_template_3” for every post of my CPT.

After update I lost this relationship, it seems always load single.php+loop-single.php.

Best regards

Lucian
tagDiv Staff

Hi,

1/2/3 Unfortunately these theme features are built to work just with posts not pages and to make them support and use pages you need to customize the theme and practically rebuild the function for related articles or socials.
Currently we’re working on adding custom post types support for blocks so once this support will be implemented pages could also be used as CPT like you need them now. Sorry!

a) That section is set with css to have a maximum width of 252px, you can rewrite tat rule using this css: http://screencast.com/t/iQh6wzCx9M

.block-mega-child-cats {
max-height: 500px;
}

Add it in theme panel > custom css section.

b) Unfortunately not because the load more/infinite or next/prev pagination only works on blocks and it can’t be used on loops. Sorry!

c) If you can’t find it in trash to restore it: http://screencast.com/t/icNXEwjZ8rH you can rebuild it and use this content, it’s the demo contact page content: http://pastebin.com/eTt6WVNShttp://demo.tagdiv.com/newspaper/contact/

d) I see you have adjusted the category to use pages so the excerpt function may also need to be adjusted to return page content, I’m not sure but you can take a look at it here: http://screencast.com/t/FKJMzRKrKWpn

Hope this helps!
Sorry for the delay!
Thanks for the message!

srikanth
tagDiv Member

Thanks for the reply.. i found the following information from the plugin author …

Add related posts automatically after the post content by using a code snippet in your (child) theme’s functions.php file

add_filter( ‘the_content’, ‘add_related_posts_after_post_content’ );
function add_related_posts_after_post_content( $content ) {

//check if it’s a single post page.
if ( is_single() ) {

// check if we’re inside the main loop
if ( in_the_loop() && is_main_query() ) {

// add your own attributes here (between the brackets [ … ])
$shortcode = ‘[related_posts_by_tax posts_per_page=”4″]’;

// add the shortcode after the content
$content = $content . $shortcode;
}
}

return $content;
}

in our theme,can we put the code in the function.php directly ??

techmarketnow
Participant
#0

Hi,
We are using NewsMag @ http://www.southindiafashion.com/ with home page as recent posts loop(no page). It has several H1 tags. We want to use H1 for site title and H2 for Article titles. Can you please let us know where and how to change it?
Thank you

lewisr90
tagDiv Member

OK great,

A bit new to this but I moved this code into my functions.php in my child theme, changed the number and it didnt work.

// Number of product per page 6
add_filter(‘loop_shop_per_page’, create_function(‘$cols’, ‘return 15;’));

if (!function_exists(‘woocommerce_output_related_products’)) {
// Number of related products
function woocommerce_output_related_products() {
woocommerce_related_products(array(
‘posts_per_page’ => 3,
‘columns’ => 3,
‘orderby’ => ‘rand’,
)); // Display 3 products in rows of 1
}
}

My question is, how do i change this without it not changing in a future update. Do I have to move the whole of the functions.php into the childtheme folder? If I did would your future updates still work?

SaL
Participant
#0

Hello there, great theme! I’ve had no problems as of yet and I’ve done quite a bit with it so far!

However I am stuck. My site has a expired tag that we use to hide posts on category pages that have this expired tag.

We used something like this on our old theme to hide specific tagged posts from category / loop.

$exclude_tags = array(6725);
$wp_query->set(‘tag__not_in’,$exclude_tags);

However I cannot get it to work on this theme.

Can an admin help me out here?

Thanks!

Viewing 25 results - 1,576 through 1,600 (of 1,749 total)