Agence Myso
Forum Replies Created
-
Forum: Hacks
In reply to: `get_posts` by months?Well, I’m sorry, I’m a bit confused, it is late here… ??
So, here is the full code for my menu :if ( is_date() ){ ?> <div class="menu2 col-lg-4 col-md-4 col-xs-4"> <?php $args = array( 'type' => 'monthly', 'post_type' => 'video', 'limit' => '', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => false, 'echo' => 1, 'order' => 'DESC' ); wp_get_archives_cpt($args); ?> </div> <div class="menu3 col-lg-4 col-md-4 col-xs-4"> <?php $month=get_query_var('monthnum'); $args= array( 'monthnum' => $month ); $my_posts = query_posts($args); foreach ($my_posts as $posts) : setup_postdata( $posts ); ?> <li><a class="post-link" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; wp_reset_postdata();?> </div> <?php } ?>
Forum: Hacks
In reply to: `get_posts` by months?Hi,
Thank you the quick answer!
Here is my code :<?php $month=get_query_var('monthnum'); $args= array( 'monthnum' => $month ); echo $month; $my_posts = query_posts($args); foreach ($my_posts as $posts) : setup_postdata( $post ); ?> <li><a class="post-link" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; wp_reset_postdata();?> </div> <?php } ?>
Forum: Hacks
In reply to: `get_posts` by months?Sorry…
When I wanted to write : “when I echo$month=get_query_var('monthnum');
”Forum: Hacks
In reply to: `get_posts` by months?Just to let you know,
I am trying to retrieve the posts date by using get_query_var, then get_posts by month.
But when I echowp_reset_postdata();
, all I get is a 0.
Anyone knows why the hell?Forum: Hacks
In reply to: Loading custom post types in two different placesExcuse me, you have “THREE” different menu items. No two.
Forum: Hacks
In reply to: Three levels category menuMan, it was so easy!
Thank you for your help.
Now everything works perfectly and I can add my menus in a very simple way! That’s so cool!Forum: Hacks
In reply to: Three levels category menuOk, I found a solution.
It is impossible to call for get_category in a custom post typesingle
template.
So I made an else if after the first ìf ( is_category() )`.
The only problem remaining is that it is very heavy (I have to paste the whole piece of code concerningwp_nav_menu
andget_post
.
Any idea on how to lighten it?Forum: Hacks
In reply to: Three levels category menuThank you for this smart answer.
If I do an if on this :if( is_category() || is_single() ) { $cat = get_query_var('cat'); $category = get_category( $cat ); if ( is_category(26) || $category->category_parent == 26 ):
and then load the category menu and the video post types, everything works until I get to the
single
template (I click on a video).
Once I am on the ‘single’ template, I get this error :NOTICE: UNDEFINED PROPERTY: WP_ERROR::$CATEGORY_PARENT IN /APPLICATIONS/MAMP/HTDOCS/SUPERGRAFIC/WP-INCLUDES/CLASS-WP-ERROR.PHP ON LINE 78
There is something I don’t understand in the wp system…
Can’t it be a problem linked to the fact that I am working with custom post types?Forum: Hacks
In reply to: Three levels category menuArg… I can’t get it to work…
I’ve tried to add a single-video.php file, but it does not solve anything… Each time I click on a video file, my menu disappears, as if I was at the root level of the site…Forum: Hacks
In reply to: Three levels category menuHi and happy new year!
How funny it is, I was just thinking I would rename my single.php in single-video.php just to try!Forum: Hacks
In reply to: Three levels category menuI think I’ll have to be more specific…
The video must appear just next to the menu, on the right. So the user has the menus AND the video player on the same page. Exactly as it is on https://www.supergrafic.com right now.Forum: Hacks
In reply to: Three levels category menuI am facing new problems… ??
When clicking on a video link, the user gets to a “single” template. The problem in my structure is I can’t get to make the menu appear on this single template as it is on the archive template. I tried to create a single.php file, but that didn’t work.
Any idea?Forum: Hacks
In reply to: Three levels category menuThanks for your advice!
I’m nearly done! Hope all this will help someone else one day.
I’ll put the whole piece of code as soon as it is finished.Forum: Hacks
In reply to: Three levels category menuWOW! WordPress is brilliant!
I just found that if you call to wp_list_categories as a list (‘style’ => ‘list’), you get some very cool css classes : ‘current-cat’ and ‘current-cat-parent’ !!
This way I can already highlight two levels : parent category and subcategory. Now the only thing left to be done is highlight the current post in the list and I’m done!Forum: Hacks
In reply to: Three levels category menuOk, so, I need users (anonymous users) to know in which parent / category they are and which video they are looking at. It needs a class “active” on three levels ate the same time. I guess it can be done with something like get_categories and get_categories->parent, but I can’t figure it out clearly right now…
Here is my code :<div class="navigation col-lg-4 col-md-4 col-xs-4"> <div class="col-lg-4 col-md-4 col-xs-12"> <?php $args = array( 'show_option_all' => '', 'orderby' => 'name', 'order' => 'ASC', 'style' => 'none', 'show_count' => 0, 'hide_empty' => 0, 'use_desc_for_title' => 1, 'child_of' => 0, 'feed' => '', 'feed_type' => '', 'feed_image' => '', 'exclude' => 1, 'exclude_tree' => '', 'include' => '', 'hierarchical' => 1, 'title_li' => __( 'Categories' ), 'show_option_none' => __( 'No categories' ), 'number' => null, 'echo' => 1, 'depth' => 1, 'current_category' => 0, 'pad_counts' => 0, 'taxonomy' => 'category', 'walker' => null ); wp_list_categories( $args ); ?> </div> <div class="col-lg-4 col-md-4 col-xs-12"> <?php if ( is_category() ) { $cat = get_query_var('cat'); $args = array( 'include' => $cat, 'hide_empty' => 0 ); $categories = get_categories($args); if ( ($cat == 21) || ($categories[0]->category_parent == 21) ) : $defaults = array( 'theme_location' => '', 'menu' => 'video_categories', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '', 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', 'depth' => 0, 'walker' => '' ); wp_nav_menu( $defaults ); ?> </div> <div class="col-lg-4 col-md-4 col-xs-12"> <?php $categories = get_the_category(); if ($categories) { $category_id = $categories[0]->cat_ID; } else { $all_cats = get_categories(); foreach ($all_cats as $value) { if(is_category( $value->slug )) { $category_id = $value->cat_ID; } } } if (isset($category_id)): $videos = array( 'posts_per_page' => 99, 'post_type' => 'video', 'category' => $category_id, 'orderby' => 'menu_order', 'order' => 'DESC' ); $cat_posts = get_posts( $videos ); foreach ( $cat_posts as $post ) : setup_postdata( $post ); ?> <li><a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a> </li> <?php endforeach; wp_reset_postdata(); endif; ?> </div> <?php endif; } ?> </div>