Hi,
If you need the category id’s, you can get them like so: http://screencast.com/t/FNQsNMe2moG
If this is not what your request, then please provide more details so we can understand better how to help.
Thank you!
Hello.
No i don’ t want this.
If in one page i have a big grid 5 shortcode. And i have set to that big grid 5 to show posts from the category “fashion”. I want progrmmaticaly with php in the file wp-content/themes/Newspaper/includes/shortcodes/td_block_big_grid_5.php to can take the id from fashion category “91”. I want this because i want in that page to show all the posts from fashion category with the big grid 5 style. But to do this i want to find first the category id which has set at the big grid 5 settings in that page, and after to find how many posts from this category are published in my posts.
So how can i with php to fish the category id which is set at the big grid 5 settings;i want to fish it in the wp-content/themes/Newspaper/includes/shortcodes/td_block_big_grid_5.php file
Thank you
Hi,
Unfortunately neither of us can understand what it is you want to achieve. As I understand it, you want a page with multiple big grid 5 elements that show the same category. This is easily done from the block settings themselves. Create a page and add as many big grids as you want and filter them with that particular category and either use an offset or activate unique articles. The re is no other ID than the one I pointed in the reply above.
The category in the files is grabbed with this function : https://developer.wordpress.org/reference/functions/get_category/
The code you seek is NOT in td_block_big_grid_5, but rather in the module file newspaper/includes/modules/td_module_mx12.php
http://screencast.com/t/eXSPNfQbLx
The get_category function is simply called here, but it is located here:
http://screencast.com/t/mKxbqUfFb2mV
So as you can see it gets more complicated. It’s much easier to simply use the theme settings where you can and avoid changing the theme files as much as possible.
Thanks.
Sorry for missunderstanding, maybe is my fault.
i want some pages to have one big grid 5, which will saw all the posts from one category in one big grid 5 (all posts in lines with three posts at every lne, like big grid 5).
with your answer in a prebuying queston:
2. The Big Grid blocks have a limit for posts in the code so you can change it there. Lets take your example Big Grid 5, here you can change the limit – http://screencast.com/t/XmOZHeiWG8F and the result – http://screencast.com/t/EX7UYmjZbK Please note that the Big Grids were designed to handle only a specific number of articles and for some of them you may need additional customizations(big grid 5 seems to work fine even you set it to display more posts). So if you have also basic html/css experience should not be an issue.
I modfied a little the file wp-content/themes/Newspaper/includes/shortcodes/td_block_big_grid_5.php
<?php
/**
*
* Class td_block_big_grid_5
*/
class td_block_big_grid_5 extends td_block {
//const POST_LIMIT = 20;
function render($atts, $content = null){
//Gia na parw to plithos twn posts sthn katigoria
$postsInCat = get_term_by('slug','men-s-lifestyle','category');
$postsInCat = $postsInCat->count;
echo $categories[0]->term_id;
// for big grids, extract the td_grid_style
extract(shortcode_atts(
array(
'td_grid_style' => 'td-grid-style-1'
), $atts));
//$atts['limit'] = self::POST_LIMIT;
$atts['limit'] = $postsInCat;
parent::render($atts); // sets the live atts, $this->atts, $this->block_uid, $this->td_query (it runs the query)
$buffy = '';
$buffy .= '<div class="' . $this->get_block_classes(array($td_grid_style, 'td-hover-1')) . '">';
$buffy .= '<div id=' . $this->block_uid . ' class="td_block_inner">';
$buffy .= $this->inner($this->td_query->posts); //inner content of the block
$buffy .= '<div class="clearfix"></div>';
$buffy .= '</div>';
$buffy .= '</div> <!-- ./block -->';
return $buffy;
}
function inner($posts) {
$postsInCat = get_term_by('slug','men-s-lifestyle','category');
$postsInCat = $postsInCat->count;
$buffy = '';
$td_block_layout = new td_block_layout();
if (!empty($posts)) {
$buffy .= '<div class="td-big-grid-wrapper">';
$post_count = 0;
foreach ($posts as $post) {
$td_module_mx12 = new td_module_mx12($post);
$buffy .= $td_module_mx12->render($post_count);
$post_count++;
}
//if ($post_count < self::POST_LIMIT) {
if ($post_count < $postsInCat) {
//for ($i = $post_count; $i < self::POST_LIMIT; $i++) {
for ($i = $post_count; $i < $postsInCat; $i++) {
$td_module_mx_empty = new td_module_mx_empty();
$buffy .= $td_module_mx_empty->render($i);
}
}
$buffy .= '</div>';
}
$buffy .= $td_block_layout->close_all_tags();
return $buffy;
}
}
But there is a need to make more pages like this. In the one for category “Men’s Lifestyle” is working perfect.
But if i have at the menu three menus “a,”b and c” (which are coming from three diferent pages), and in every page i have a big grid 5 which in settings have at category filter, at page “a” the category “a”, at page “b” the category “b” and at page “c” the category “c”, there is no way to change the code and some how to take the category which we have set at settings in the big grid 5?
so in this code:
$postsInCat = get_term_by('slug','men-s-lifestyle','category');
$postsInCat = $postsInCat->count;
the :”men-s-lifestyle” to come from code, or to change it at $postsInCat = get_term_by('id',20,'category');"
and the number (id) 20 to can take it with code before.?
I hope to understand what i mean now.
The example page i created wth the above modificaton , you can see it here: http://testgeolits.myipservers.gr/Olaballa/?page_id=136
Hi,
I understand now what you want to do, but if you simply change the limit for the big grid 5 element, what’s stopping you from filtering specific categories to it? It’s not like the block will remain stuck with just one category in it’s filter. You can create as many instances of the element as you want and filter it differently from block settings. Simply change the limit like so: http://screencast.com/t/rl0GWM5b and now you can have multiple posts in the big grid, but it will not lose the filters. You can create a page and filter category A, then create another page and filter category B and so on. You can filter categories from the block settings: http://screencast.com/t/gjj0zkEuLxh This way you can have multiple pages with big grid 5 and different categories filtered in the blocks.
Thanks.
Hi gain and thank you.
I done this at first. But after this, if i change only the limit, then i must have, my tinking if the post reach the limit. Also if we put the limit lets say at “5000” then it will create 5000/3=1666 lines, from which will fill only the number from posts which are at this time (now) attached at this category, lets say 10. So the result will be a very big page displaying only 10 posts.
So with my indervation i have the limit at the number of posts the category “mens lifestyle” has. So if i have 30 posts in category “mens lifestyle”, then the page will create only 30/3=10 lines and will display the page in the right height to display only the 30 posts from category “mens lifestyle”.
So the dificulty for me now is if i have multiple pages, for diferent category every page, in someway to can have the category id, and after this to have the limmit at the number of posts which are asigned at this category.
As the big grid 5 is a class, i assume that every page which have inside a big grid 5, will have an object of this big grid 5 class. And as the big grid 5, have at settings the category filtering, then that object will have in its attributes the category id.
So can you help be how to retrieve this id, in this file wp-content/themes/Newspaper/includes/shortcodes/td_block_big_grid_5.php (which i assume that is the class for the big grid 5 object)?
thank you
I understand, but there is a simpler way to do it. The empty space is being added by code, not generated automatically. You can simply remove this part of the code: http://screencast.com/t/JIvv6J4xd2 and there will be no more extra space added to the grid.
before: http://screencast.com/t/zZxixaq8M
after: http://screencast.com/t/2Abcc07f
Hope this helps.
They were added as a design choice so if there are only 2 posts or one post in the grid (in the specified filter), the container would be visible like so: http://screencast.com/t/bNJc9a6ac
Simple aesthetics, nothing more.
Thank you!