New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems with custom post types #656
Comments
You should use $context['blogposts'] = Timber::get_posts('post_type=blogposts'); in your custom single-...php and not $context[post] |
Try to use twig dump on blogposts, you should get a array |
Hm, i didn't understand at all (my english is not the best, sorry about that), but, you are talking about for something like this in my single-blogposts.php: <?php
$context = Timber::get_context();
$post = Timber::get_posts('post_type=blogposts');
$context['blogposts'] = $post;
Timber::render('single-blogposts.twig');
?> I tried this but nothing happens when the permalink is clicked on the list of articles. I'm a noob, sorry u.u Edit: Added the second parameter
|
Your clicking the permalink in backend? or on a post? can you make a vardump on var_dump(Timber::get_posts('post_type=blogposts')); And check if you get a output? Because i don't know where you clicking the permalink. |
Okay, im clicking it in the post, here: And, the dump of bloposts is: Array ( [0] => TimberPost Object ( [ImageClass] => TimberImage [PostClass] => TimberPost [object_type] => post [_custom_imported:protected] => [_content:protected] => [_get_terms:protected] => [_permalink:protected] => [_next:protected] => Array ( ) [_prev:protected] => Array ( ) [class] => post-453 blogposts type-blogposts status-publish has-post-thumbnail hentry category-blogpost [display_date] => 26 agosto, 2015 [id] => 453 [ID] => 453 [post_author] => 1 [post_content] => Me gustaria ver si esto funciona, estoy usando texto real para evitar los cortes raros de los lorem ipsum, cosa de ver que pasa. Más párrafos son necesarios, y la gente de sabadell jode como solo ellos, pero vale, pagan por esto y por esto gano dinero. ¿Algo más? Oh si, estoy hasta los huevos HASTA LOS HUEVOS [post_date] => 2015-08-26 16:02:50 [post_excerpt] => [post_parent] => 0 [post_title] => Hasta los huevos [post_type] => blogposts [slug] => hasta-los-huevos [_edit_last] => 1 [_edit_lock] => 1440604841:1 [_thumbnail_id] => 295 [post_date_gmt] => 2015-08-26 16:02:50 [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => hasta-los-huevos [to_ping] => [pinged] => [post_modified] => 2015-08-26 16:02:59 [post_modified_gmt] => 2015-08-26 16:02:59 [post_content_filtered] => [guid] => http://shirley:8080/wordpress/?post_type=blogposts&p=453 [menu_order] => 0 [post_mime_type] => [comment_count] => 0 [filter] => raw [status] => publish [custom] => Array ( [_edit_last] => 1 [_edit_lock] => 1440604841:1 [_thumbnail_id] => 295 ) ) [1] => TimberPost Object ( [ImageClass] => TimberImage [PostClass] => TimberPost [object_type] => post [_custom_imported:protected] => [_content:protected] => [_get_terms:protected] => [_permalink:protected] => [_next:protected] => Array ( ) [_prev:protected] => Array ( ) [class] => post-445 blogposts type-blogposts status-publish has-post-thumbnail hentry category-blogpost [display_date] => 26 agosto, 2015 [id] => 445 [ID] => 445 [post_author] => 1 [post_content] => Me gustaria ver si esto funciona, estoy usando texto real para evitar los cortes raros de los lorem ipsum, cosa de ver que pasa. Más párrafos son necesarios, y la gente de sabadell jode como solo ellos, pero vale, pagan por esto y por esto gano dinero. ¿Algo más? Oh si, estoy hasta los huevos [post_date] => 2015-08-26 14:33:51 [post_excerpt] => [post_parent] => 0 [post_title] => Este es un post de pruebas [post_type] => blogposts [slug] => hola-mundo-2 [_edit_last] => 1 [_edit_lock] => 1440604857:1 [_thumbnail_id] => 289 [post_date_gmt] => 2015-08-26 14:33:51 [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => hola-mundo-2 [to_ping] => [pinged] => [post_modified] => 2015-08-26 16:03:19 [post_modified_gmt] => 2015-08-26 16:03:19 [post_content_filtered] => [guid] => http://shirley:8080/wordpress/?post_type=blogposts&p=445 [menu_order] => 0 [post_mime_type] => [comment_count] => 0 [filter] => raw [status] => publish [custom] => Array ( [_edit_last] => 1 [_edit_lock] => 1440604857:1 [_thumbnail_id] => 289 ) ) [2] => TimberPost Object ( [ImageClass] => TimberImage [PostClass] => TimberPost [object_type] => post [_custom_imported:protected] => [_content:protected] => [_get_terms:protected] => [_permalink:protected] => [_next:protected] => Array ( ) [_prev:protected] => Array ( ) [class] => post-441 blogposts type-blogposts status-publish has-post-thumbnail hentry category-blogpost [display_date] => 26 agosto, 2015 [id] => 441 [ID] => 441 [post_author] => 1 [post_content] => No, en serio, me caen mal... ¿Alguien tiene idea de lo que es trabajar para esta gente? Joden demasiado y pagan poco, ellos lo saben, somos mano de obra barata pero quieren que les demos productos de calidad por lo poco que pagan. Look at dat descaro. Cojones [post_date] => 2015-08-26 14:09:13 [post_excerpt] => [post_parent] => 0 [post_title] => Estas putas me caen mal [post_type] => blogposts [slug] => esta-es-una-prueba [_edit_last] => 1 [_edit_lock] => 1440605065:1 [_thumbnail_id] => 219 [post_date_gmt] => 2015-08-26 14:09:13 [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => esta-es-una-prueba [to_ping] => [pinged] => [post_modified] => 2015-08-26 16:04:25 [post_modified_gmt] => 2015-08-26 16:04:25 [post_content_filtered] => [guid] => http://shirley:8080/wordpress/?post_type=blogposts&p=441 [menu_order] => 0 [post_mime_type] => [comment_count] => 0 [filter] => raw [status] => publish [custom] => Array ( [_edit_last] => 1 [_edit_lock] => 1440605065:1 [_thumbnail_id] => 219 ) ) ) |
The real problem is get the single content when i click the link in the lists of articles, like a normal blog behavior, this is the think that i cant do |
try to use <hgroup><h2><a href="{{post.get_path}}">{{post.title}}</a></h2></hgroup> |
I used {{post.title}}, the problem is when i click in this title (with {{post.link}}) i get a 404... :/
|
@nanotime what page are you actually taken to when you get the 404? as in, what's outputted inside of the |
Hmm, ok for some extrange reason it begins to "work" but not at all, let me brake this in parts: First @jarednova my 404 is the same at timber starter theme, i dont touch it (im using the starter theme), so: <?php
/**
* The template for displaying 404 pages (Not Found)
*
* Methods for TimberHelper can be found in the /functions sub-directory
*
* @package WordPress
* @subpackage Timber
* @since Timber 0.1
*/
$context = Timber::get_context();
Timber::render( '404.twig', $context ); Then, my Permalink config: %postname% (my instalation is in spanish, sorry) The href output is Again, i have NO IDEA why, but it begins works suddenly P.D: I can't stop to apologize for my English, I know I have tons of errors |
No prob., glad it kicked in for you! |
Hi! Im new with this and well, i have a little problem... Well, i create a new custom post type and capture it in the context of a page (to make a internal blog for one site).
For now i get all the posts and i present there in the template without problems but, when i try to get into a post (you know, clicking the permalink) it just retrieve me a 404.
Here is the code:
The custom post (fragment)t in functions.php (works perfectly)
The page.php getting the special post (works without problems)
The custom page.twig (it works perfectly)
Now, the problem is with the single, i tried some things like: create a
single-blogposts.php
and thesingle-blogposts.twig
Try to use like the video tutorials in the index and making a
tease-blogposts.twig
and getting the posts in theindex.php
and so on...Nothing works :/ ¿Any idea? I just need this to finish the proyect and i have no more hints or ideas.
The text was updated successfully, but these errors were encountered: