Hot answers tagged

5

The workhorse is WP_Theme::get_page_templates() (wrapped by the helper function get_page_templates()). If you check out the source, you'll see: /** * Filter list of page templates for a theme. * * @since 3.9.0 * @since 4.4.0 Converted to allow complete control over the `$page_templates` array. * * @param array $page_templates Array of page ...


2

You could filter the include paths returned by get_included_files by removing any files from the list that are not in your theme (and/or child theme) directory: function get_theme_includes() { $includedfiles = get_included_files(); // normalize theme paths for matching $styledir = str_replace("\\","/",get_stylesheet_directory()); ...


2

I can already tell that you're using ACF - if you don't want to change the return settings for the field, you can bypass ACF and just pull the image ID directly from post meta: $image_url = get_field( 'my_field_name' ); $image_id = get_post_meta( $post->ID, 'my_field_name', true ); $image_meta = wp_get_attachment_metadata( $image_id );


2

Use wp_enqueue_scripts instead on init. This will ensure you the template is already loaded. add_action('wp_enqueue_scripts', 'maps_scripts'); Or you try to check the template using get_page_template_slug() instead of is_page_template: $tmp = get_page_template_slug($post_id); // provide page/post ID if('page-about.php' == $tmp) { // enqueue scripts ...


2

Custom page templates are for pages - not post type archives :) Naming your template file as archive-projects.php will cause Wordpress to select it for your Projects archive page. You also don't need the /* Template Name: Projects */ in there, as this template naming is default Wordpress behaviour. See the visual overview of the template hierarchy to ...


2

Paging a list of terms/categories/tags are quite easy, and to achieve that, you need minimal info. Lets look at we need the amount of terms the amount of terms per page get_terms() (Just note, the usage of get_terms() have changed in version 4.5). You can also use get_categories() if you wish, get_categories() is just a wrapper function for get_terms() ...


1

I'm not familiar with WP-PageNavi, but I suspect it assumes to be dealing with posts, so it might easily screw up if you use it on a loop like yours. Perhaps the css might still be helpful in styling your html. Anyway, setting up your own pagination is not that difficult. First, you need to know how many categories there are: $cat_amounts=count($cats); ...


1

Great question. As far as I can tell there isn't a way to filter this list (there's a long trac ticket about a proposal to, if you're interested, and also related (but different) questions on this site here and here). Because there's no filter, you may have to resort to doing it with jQuery. We can add our own scripts to the admin footer using the ...


1

Your code is invalid (syntax error, missing closing array and semi-colon), and incorrectly nested - if you were to properly indent your code, you'd have something like: $args = array( 'tag' => 'tag-AAA,tag-BBB', array ( 'orderby' => array( 'title' => 'ASC', 'post_date' => 'DESC', ...


1

Technically, third party plugins are off-topic for this site. However this is an easy one - in the Custom Fields page in the admin area, go into your field group. Scroll right down to the bottom and there's a section allowing you to "hide" elements in the post. Select the "content" option here and you're done. Keep in mind that if you have multiple field ...


1

Well I was privileged enough to get the tumbleweed badge for this question. But I found the answer. Easy enough. Custom Upload Dir Plugin. Perfect for the job. Well, almost. With a little tweaking.



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