Hot answers tagged

2

Flushing the rewrite rules - which you can do just by visiting the Settings -> Permalinks page - was a good step to take, because it's usually the overlooked cause of these sorts of issues. However as Milo said in the comments, in this case, it's just that the publicly_queryable argument needs to be true if you want these posts to display on the frontend. ...


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

I think you should be able to do this with the user_has_cap filter. Because that filter passes through the post ID in the $args for the edit_post capability, you can use that to check if the current user has been artificially given this capability - and if so, force the edit_post capability to be true for that instance. Building from the example in the ...


2

There is no order_by. Change order_by to orderby and it should work. The default value of compare is = so it is unnecessary, you can remove it. Also, you should specify type of the meta_value if it is a specific type rather than the default CHAR.


1

You can call https://codex.wordpress.org/Function_Reference/get_ancestors within your template. It'll return an array of ancestors to your current post and you can use the length of the array to see how deep you are in your hierarchy. Use it at the top of your template file to set a variable $post_depth and use that to adjust your body_class for targeted ...


1

If I get this right each of your posts have one value of Exercise and one Value of Tempo? I would do the following probably: Build a list of exercises. For each exercise query query: 1 posts, ordered by Tempo, descending. This is probably as good as it gets staying within realm of WP API. Might not be practical for high counts of Exercises, it's all ...


1

You first have to build a query for your posts, and inside that query you would get all your custom fields and compare them. You could use a plugin like CMB2 to build repeatble grouped fields so you can get the exercises grouped (all Excercises1, all Excercises2, etc) and also asign each to have a TEMPO field attached to that group. It would be easier then ...


1

You need to query the db using wp_query to get all the posts from the CPT, save the metabox contents to an array and then print the array. Not tested but should work (i hope): <?php $select_array = array(); $args = array ( 'post_type' => 'your_cpt', ); $query1 = new WP_Query( $args ); while ( $query1->have_posts() ) { $query1->the_post(); ...



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