How to remove this function from the homepage?
Use is_front_page() and bail at the start of the function if true: function wpb_last_updated_date( $content ) { if ( is_front_page() ) { return $content; } // Rest of your function }
Use is_front_page() and bail at the start of the function if true: function wpb_last_updated_date( $content ) { if ( is_front_page() ) { return $content; } // Rest of your function }
Short answer: DON’T DO IT! Even if yesterday you said tomorrow! Including WordPress’s core in some other files is the last thing you want to do. Instead, use an Ajax method and fill the content by using a REST endpoint. You need to register a rest route first. To do so, add this piece of … Read more
The customizer API offers active_callback methods on both the control andd section classes. Basically you use either an conditional or a custom function to determine if a control or section is shown to the user. If you want a section to appear only for pages, you would do somthing like this: $wp_customize->add_section( ‘wpse_283821_acme_pages’, array( ‘title’ … Read more
If you are using a child or custom theme, I encourage you to look at the Codex’s Template Hierarchy. The short answer to your question is yes, you can run custom code on any page you’d like. The longer answer is still yes, but it’s a bit more involved in what your end product is … Read more
Correct solution provided by Milo in comment above. Pretty permalinks were set to plain in the admin interface and this evidently causes the WP_Rewrite to silently do nothing. I’m posting the answer here so I can mark something as correct/complete so this shows as answered. Am I doing it wrong?
the call at the anonymous function is done after all the executions of add_new_page. then you need to store all elements to create menu items. try to modify the class Helper like that public function __construct() // method to modify { add_action(“admin_menu”, [$this, “add_admin_menu_items”]); } public function add_new_page( $opt ) // method to modify { … Read more
This is something that will need to be handled in the search results template of your theme. If the theme is off the shelf then it likely won’t support thumbnail images for attachments because — as you have experienced — attachments do not normally appear in search results. This is because in a normal theme … Read more
OMG… No, no, no!!! Never do that this way… Why? There are many reasons… You won’t be able to do anything with users in your views.php – what if you’ll have to count only views by anonymous (not logged in) users? What if table_prefix is set to ”? Your posts table will cause conflicts… What … Read more
Without knowing exactly what you are trying to do, it seems you want to append query variables to the URL. WordPress has methods for handling that properly, without manual string concatenation. Look at the documentation for add_query_arg() for details: https://developer.wordpress.org/reference/functions/add_query_arg/ You can rebuild the URL and append query variables to the URL query by using … Read more
Try this way: $args = array( ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post_status’ => ‘publish’ ); if ( isset( $_POST[‘typefilter’] ) && $_POST[‘typefilter’] !== ” ) { $args[‘post_type’] = ‘post_type_x’; $args[‘tax_query’][0][‘taxonomy’] = ‘type_emp’; $args[‘tax_query’][0][‘field’] = ‘id’; $args[‘tax_query’][0][‘terms’] = $_POST[‘typefilter’]; $args[‘tax_query’][0][‘operator’] = ‘IN’; } if ( $_POST[‘typefilter’] == ”) { $args[‘post_type’] = ‘post_type_x’; } // If … Read more