New answers tagged

0

Your current meta query embodies the logic IF event_end IN range OR event_start IN range You need to account for the conditions of event_end's presence separately: IF event_end IN range OR ( event_end NOT EXISTS AND event_start IN range ) Immediately adjacent nested clauses with the same AND/OR relation can be combined, which might make things a bit more ...


1

Make Columns Sortable By default the new custom columns are not sortable so this makes it hard to find data that you need. To sort the custom columns WordPress has another filter manage_edit-post_sortable_columns you can use to assign which columns are sortable. When this action is ran the function will pass in a parameter of all the columns which are ...


0

I was using a custom query and needed to paginate my query results. Since the original paginate_links() function is heavily tied to the global $wp_query and $wp_rewrite contexts, I have adapted it to be completely independent. usage: function myPaginateLinks( WP_Query $wp_query, $args = '' ) { global $wp_rewrite; // Setting up default values based ...


0

Please Flash or change permalink and save. Dashboard -> Setting -> permalinks -> Change Or flash Then Save setting.


0

And here's the answer to the issue : it was the fact that I named one of my custom taxonomy as year, which probably generated some issues in the query for static pages... Should have noticed that sooner, but hey, at least it's fixed !


0

Tom's comment on the question makes a very important point: unless you are just using this SQL for diagnostic or exploratory purposes, there is almost definitively an easier and more efficient means to access this data, either through the WordPress APIs or via tools like WP CLI. There is virtually no reason to use this SQL for logic within a WordPress plugin,...


0

I think your problem related to wptexturize() function. Description Returns given text with transformations of quotes into smart quotes, apostrophes, dashes, ellipses, the trademark symbol, and the multiplication symbol. Solution: remove_filter( 'the_title' , 'wptexturize' );


1

It's Not (Reasonably) Possible (Yet) :( This was such an interesting question to dig into. In short, we can get really, really close to accomplishing this using Block Filters and some hackish duct-tape on the PHP side. But it falls apart in the home stretch. It's worth noting that the crux of the complication is specific to the Latest Posts block's ...


0

In the scope of the code presented, $post is not defined. In order to use the $post global, you need to declare it as global beforehand (usually at the top of the function body which utilizes it): global $post; $id = $post->ID; That said, directly interacting with globals is generally discouraged as you're often accessing WordPress's raw state data, ...


0

If anyone is facing the issue mentioned above by Mnstd this little patch should allow users to delete posts using get_delete_post_link() while still keeping them away from /wp-admin/ function block_users_backend() { $current_url = $_SERVER['REQUEST_URI']; if ( is_admin() && ! current_user_can( 'administrator' ) && ! wp_doing_ajax() &...


0

I had the same problem. I tried every solution provided in most of the forums. But the actual solution that worked for me was the post type was the length of post_type. The post_type length is limited to 20 characters. So anyone who has a similar issue try this if anything else didn't work.


0

This is a powerful little snippet to allow filtering your post or custom post type by a specific taxonomy term in the WordPress admin. /* Filter CPT via Custom Taxonomy */ function rave_core_backend_by_portfolio_taxonomies( $post_type, $which ) { // Apply this to a specific CPT if ( 'portfolio' !== $post_type ) return; // A list of ...


1

I've ensured that the Representative role has read/edit/create/publish post capabilities Okay, that's good. But did you also assign the level_<number> capability to the role, where the <number> is at least 1? If not, then at least the users in the role need to be manually assigned the level 1 or a greater level (2, 3, etc.). And the reason is ...


0

Solution: I duplicated taxonomy.php template in theme folder and named it taxonomy-news-business.php then I edited the code inside this template So the result is that now all posts in CUSTOM POST TYPE with slug news with category businesss are displayed according this template because taxonomy template hierarchy in WordPress is taxonomy-{taxonomy}-{term}.php


0

There are several ways to achieve a new front page, here it goes my favorite two. if the theme already has a front-page.php, just overwrite it with the new code. if it doesnt create a front-page.php file and copy the code wanted over there. it should work like a charm. create a template, create a page , set the page to that template and go to wp dashboard ...


0

Note that you should use %<post type>% in the slug value, so if the post type is test_cpt, then you would use %test_cpt% as in /a/%test_cpt%/b/c. And moving the post name/slug to the middle or beginning in the permalink structure is actually pretty easy: Register the post type: // replace test_cpt with the correct post type register_post_type( '...


2

it is stored in the post_name field in database. you can utilize the following code if you are inside a loop: $the_slug = get_post_field( 'post_name' ); or if you are outside the loop: $the_slug = get_post_field( 'post_name', $post_id); where $post_id is the id of the post you want to retrieve from.


0

Its working for me add_action('admin_head', 'my_custom_fonts'); function my_custom_fonts() { echo '<style> a.page-title-action { display: none !important; } ul.wp-submenu.wp-submenu-wrap { display: none !important; } } </style>'; }


0

I think this might be part of the problem in your past query (the second one) array( 'key' => 'end_date', 'compare' => 'BETWEEN', 'type' => 'NUMERIC', 'value' => array($past, $now), ), You're using BETWEEN but I think something like < would be what you want. You don't ...


0

ok - so this isn't what I wanted but it does the trick. Adding a function to redirect when the user hits any term but one: function my_page_template_redirect() { if( is_singular( 'custom-post-type' ) && !(has_term('term', 'custom-taxonomy')) ) { wp_redirect( home_url(), 301 ); exit(); } } add_action( 'template_redirect', '...


0

It might just be the late hours, but the register_taxonomy call looks wrong. Shouldn't the second parameter be the post type you're registering the taxonomy for? I.e. array('pdsh_posts'). And yes, you need to register each of the three taxonomies separately for the post type. See the codex example, https://developer.wordpress.org/reference/functions/...


0

May be this thread could be useful to you: Also you could explain a bit more what's the pourpouse of those images. Are they going to be printed in the fontend or in the admin side? Do you need them to be uploaded from the frontend or they can be retrived from the wordpress media uploads ? If so, you could create a src field in order to get the image source ...


2

Background Even after looking around everywhere, I couldn't find a proper solution for removing CPT slug from permalinks that actually works and is consistent with how WordPress actually parses requests. As it seems, everyone else looking for the same solution is in the same boat as me. As it turns out, this is actually a two-part solution. Remove CPT slug ...


Top 50 recent answers are included