Hot answers tagged

8

See this famous answer by the equally famous Rarst. Here he charts out the load process of WordPress which hasn't and isn't expected to change any time soon. The process pretty much goes: WordPress Core Must-Use Plugins ( mu-plugins directory ) Plugins Themes ( Child before Parent )


4

WordPress has a perfect wrapper for HTML > Theme conversion: The theme itself. All information can be found in the Codex page. It is enough to add a folder to your wp-content/themes directory (or whatever directory you registered in addition to that), and add the following files functions.php style.css index.php header.php to your custom themename ...


2

The admin-init hook only fires on admin screens. The correct hook to use for registering post types is init. So change: add_action( 'admin_init', 'smoelenboek' ); ... to ... add_action( 'init', 'smoelenboek' ); ... and flush your rewrite rules once (save permalink settings in admin) and all should be well.


2

It can be done and you can do a quick (relatively) job or take more time on a better site->WP conversion. I'm going to assume that you can write a theme, or this post will turn into a whole book. If not their are many guides online & in print and you don't need to become a full theme expert to get this conversion started. And we can fine tune my ...


1

Custom taxonomies have templates named taxonomy-something in this hierarchy: taxonomy-{taxonomy}-{term}.php taxonomy-{taxonomy}.php taxonomy.php archive.php index.php So, yes, if you have no taxonomy-custom-cat-term-cat.php, taxonomy-custom-cat.php or taxonomy.php then archive.php will be used. category-something.php will only be used for the built-in ...


1

Don't use template_redirect to load alternate templates as you can break any functionality that uses this hook to run on a lower priority than yours. The right hook is template_include. This is according to Mark Jaquith, one of the WP lead developers. https://markjaquith.wordpress.com/2014/02/19/template_redirect-is-not-for-loading-templates/ That said, ...


1

You need to get the title for each post ID in your array. The straightforward way is this: $procedure_title_list = array(); $procedure_list = get_post_meta($patient_story->ID, 'Procedure', false); foreach ( $procedure_list as $procedure ) { $procedure_title_list[] = get_the_title( $procedure ); } echo implode( ', ', $procedure_title_list );


1

You could use switch_theme function. Accepts one argument: $stylesheet of the theme. ($stylesheet is the name of your folder slug. It's the same value that you'd use for a child theme, something like "twentythirteen".) Documentation: switch_theme


1

You can just run through the loop and set a flag: if ( $query->have_posts() ) : $any_in_cat = false; while ( $query->have_posts() ) : $query->the_post(); if ( in_category( 'first-major' ) ) : $any_in_cat = true; endif; endwhile; $query->rewind_posts(); /* if $any_in_cat == true at this point then ...


1

You can create a separate function to check your array of posts contains a post with that category. It will basically do what you are now but it will allow you to call the function once instead of each time through the loop. You would put this code in your functions.php file: function does_array_contain_category( $categories, $posts ){ foreach( $posts ...


1

To expand your conditional to check for display of one of your terms, you can do this: if ( is_page() ) { the_title(); } elseif ( is_tag() ) { single_tag_title(); } elseif ( is_tax( 'mtags' ); ) { single_term_title('More Tags: '); } However, if you use your theme's custom taxonomy template for this taxonomy, taxonomy-mtags.php, then you can ...


1

Remove the read more with this code in your functions.php: function wpse_230169_excerpt_more($more) { return ''; } add_filter('excerpt_more', 'wpse_230169_excerpt_more'); Then in your template file just add the link wherever you want with: <a href="<?php the_permalink(); ?>">Read More</a>



Only top voted, non community-wiki answers of a minimum length are eligible