Get markup for post without loading into the template

I couldn’t figure out a WordPress way to do this and looking at the WP source, it looks like this probably will never really be possible. However, I was able to get a solution using vanilla PHP by redirecting standard output into a buffer and loading the buffer into a variable. $listings = new WP_Query(…); … Read more

Theme settings Page: Settings Api vs Update_Options

You are not wrong about conceptual limitation, but any development convention is inherently about constraints. Constraints are “bad”, but they are also often good and important. In this specific case it’s slightly soured by Settings API being especially nasty snowflake, which historically led people to reinvent this particular wheel a lot. However, your estimate of … Read more

Display subcategories selectbox on each category page

If you are referring to the categories from the post type post (the blog) then this would do the trick: For a drop-down: wp_dropdown_categories() For a list: wp_list_categories() child_of Only display categories that are children of the category identified by this parameter. There is no default for this parameter. <?php // Put the parent category … Read more

Template_redirect for child custom post types

All sorted. For any one interested, I simply added in a function (into functions.php) that redirected to my new template dependent on the name of the post (you could also use the ID). add_filter(‘template_include’, ‘new_template’); function new_template($template){ global $post; if($post->post_name == ‘mortgage’){ $template = get_template_directory() . ‘/mortgage-template.php’; } return $template; }

Creating custom page template

Assuming that you’re on a page template or a custom page template, the first thing you want to do is grab the current page ID, then use that ID to grab the children. Once you have the children, display the content for those children. Try using get_children(); You can also try get_page_children but for my … Read more

Adding text to the footer of each post based on tags or categories

I would suggest a filter on the_content much like: function conditional_footer_wpse_165930() { if (is_single()) { if (has_category(‘cat’)) { return ‘This is the cat footer’; } } } add_filter(‘the_content’,’conditional_footer_wpse_165930′,PHP_INT_MAX); I am not sure about all of the details you require. You may need to tweak that code.

Add Date & Author Meta to Category Archive Page

This is how its done in Twenty Fourteen which uses a template tag: Note: The conditionals if ( is_sticky() && is_home() && ! is_paged() ) { will need to be changed or removed if ( ! function_exists( ‘twentyfourteen_posted_on’ ) ) : /** * Print HTML with meta information for the current post-date/time and author. * … Read more

I want to rel=nofollow wordpress images

You need to hook into the image_send_to_editor filter. This allows you to modify the markup used when inserting an image into the content editor. Something like this should work: add_filter(‘image_send_to_editor’, ‘my_add_rel_nofollow’, 10, 8); function my_add_rel_nofollow($html, $id, $caption, $title, $align, $url, $size, $alt=”” ){ // check if there is already a rel value if ( preg_match(‘/<a.*? … Read more