Noisie
Forum Replies Created
-
Forum: Themes and Templates
In reply to: Custom get functions in template<?php get_template_part(‘name’); ?>
and call the new document name.php works perfect
Forum: Themes and Templates
In reply to: Custom get functions in templateI found some more info about a solution what proberly fits me: http://codex.wordpress.org/Function_Reference/get_template_part
I hope this also works without a child theme.
Forum: Plugins
In reply to: Problem with loopProblem solved. My query was bad written what caused the problem.
<?php wp_reset_postdata(); $loop = new WP_Query( array( 'post_type' => 'posttypename', 'posts_per_page' => 20 ) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> Content.. <?php endwhile; ?>This code will make the loop work perfect after a normal query. Be sure you dont name the post_type the same as the page slug else it will bug out.
Forum: Plugins
In reply to: Problem with loopThanks for the fast reply alchymyth. The wp_reset_postdata(); did not work. I will look into how to restore $temp back to wp_query later since it is very late here and custom PHP is still hard to understand for me.
This is the full relevant code I used:
In test.php template:
<?php get_header(); /* Template Name: test template */ ?>
<ul class="submenu"> <?php $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query('showposts=10&post_type=test'.'&paged='.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <li> <?php the_title( '<a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a>' ); ?> </li> <?php endwhile; wp_reset_postdata(); ?> </ul>and after the first loop:
<div class="contentbox main"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h1><?php the_title(); ?></h1> <?php the_content(); ?> <?php endwhile; endif; ?> </div>In the functions file:
add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'test', array( 'labels' => array( 'name' => __( 'test' ), 'singular_name' => __( 'test' ) ), 'public' => true, 'has_archive' => true, 'menu_position'=>4, 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ) ) ); }What I did was create a page: test and connected the test template with the template function to connect the first query with custom post type tab with the normal page. I think I did something wrong with the flushing of the query. I used the query since it was the only one working with a numeric pagination on custom post types.
Forum: Hacks
In reply to: WordPress Slow Performance (Shared Hosting)I would look for a bit more expensive CDN host. WordPress can be really slow on some hosting company’s.
Forum: Hacks
In reply to: More classes at previous_post_linkIt works now, thank you! When I tried the double-quotes my HTML editor is calling for a error in the code because of the ‘at the span’ but I ignored it now and it works without php errors 🙂
EDIT: I have to say I tried to fill in single quotes what was triggering the error I understand now why next time I’ll use double quotes.
Forum: Hacks
In reply to: More classes at previous_post_linkThat was the first thing I tried. When I put the code like that and inspect the code with firebug the output is like this:
a rel=”next” href=”url..”>Volgende <span icon-white=”” class=”icon-chevron-right”></span>/a
I use WordPress 3.5 and the only relevant code I changed for the buttons is:
<?php previous_post_link( ‘%link’, __( ‘<span class=icon-chevron-left icons-white></span> Vorige’ ) ); ?>In my functions.php I use extra code to put a class on the anchor:
function single_btn_add_class($format){
$format = str_replace(‘href=’, ‘class=”btn btn-small btn-info” href=’, $format);
return $format;
}
add_filter(‘next_post_link’, ‘single_btn_add_class’);
add_filter(‘previous_post_link’, ‘single_btn_add_class’);It seems so simple but ive been trying all sort of things and searching on the WordPress forums for similar cases.
Forum: Hacks
In reply to: More classes at previous_post_linkI am using the Bootstrap framework with WordPress and it uses object orientated css. I am a big fan of OOC because it will keep the CSS clean and structured when a website is growing large.
In my specific case I am using a spriteset (glypthicons) what is already integrated in the Bootstrap framework. With the class=icon-chevron-left I call an arrow icon background image. With another class (icons-white) in my case i can make the background white.
The quickfix would be to overwrite the bootstrap class in styles.css. But I want to prevent that since the best solution is a extra class so the stylesheets will be as slim as possible and the style.css wont get filled with unnecessary styles.
I hope someone can help me out 🙂