Custom taxonomy query for a custom post type
I figured it out. Thanks to an answer posted here. The code is $term_slug = get_query_var( ‘term’ ); $query_args = array( ‘taxonomy’ => ‘news_category’, ‘term’ => $term_slug, ‘post_type’ => ‘news’ );
I figured it out. Thanks to an answer posted here. The code is $term_slug = get_query_var( ‘term’ ); $query_args = array( ‘taxonomy’ => ‘news_category’, ‘term’ => $term_slug, ‘post_type’ => ‘news’ );
Handle built in sizes right I wrote a class that handles all the different stuff for built in image sizes. To redefine the built in sizes, use an extended class (the upper file in the linked source) To unset a class and skip it’s useage completely, just set w & h to 0. http://static.steffenvogel.de/wp-content/uploads/2011/07/octocat_construction.gif Click … Read more
Try this – I’ve not implemented it fully, but I have tested it and it seems to work. Place it in your functions.php and call <?php list_child_pages(); ?> in your template or use the shortcode [childpages] in your editor. <?php // List Child pages of a parent. function list_child_pages() { global $post; if ( is_page() … Read more
You can update the sub sites when the main site is updated. Assuming your post IDs for the duplicated content remain the same as the same post in the main site you can write a plugin which runs only on the main site and with every save updates the sub sites add_action(‘save_post’,’wase87206_broadcast’); function wase87206_broadcast($post_id) { … Read more
If the options have “visual” impact on the website, consider using the customizer, it gives immediate visual feedback on what changing a value means. If the settings have no visual impact on the website, then maybe they don’t belong in the theme after all, but in a separate plugin. There are always edge cases, so … Read more
You want wp_get_attachment_image_src(): if ( $src = wp_get_attachment_image_src( $attachment_id, $size ) ) { echo $src[0]; // URL echo $src[1]; // Width echo $src[2]; // Height }
You can use PHP’s output buffering. WIth this you can write a wrapper for the get_head() function function wpse251841_wp_head() { ob_start(); wp_head(); return ob_get_clean(); } You can then use this as $data = array( ‘wpHead’ => wpse251841_wp_head(), ‘postContent’ => $post->post_content, ‘postContentFiltered’ => apply_filters( ‘the_content’, $post->post_content ) ); Reference: Output Control Functions
You can filter the template with the template_include filter. This example will filter the archive template for all archive pages. If you need to do this for a specific archive, use is_post_type_archive( $post_types ) as your condition. Put this in your functions.php file of your child theme. function my_archive_filter( $template) { if ( is_archive() ) … Read more
Please, update your loop part with following code: <?php $page = (get_query_var(‘page’) ? get_query_var(‘page’) : 1); $args=array(‘post_type’ => ‘gadget’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 36, ‘page’ => $page); $wp_query = new WP_Query($args); if( $wp_query->have_posts() ) { $i = 0; while ($wp_query->have_posts()) : $wp_query->the_post(); $postidlt = $post->ID; Reason before using page instead of paged. page (int) … Read more
That part is extremely rigid, see this question about loading page templates from plugin directory. With current state of related code I would not bother spending time on this. Especially since you want it for convenience (putting template in sub-directories) and not functionality (like loading from plugin folder).