Redirecting to “All Posts” after post publish or update
Redirecting to “All Posts” after post publish or update
Redirecting to “All Posts” after post publish or update
You can “load the pages” via the pre_get_posts action, like so: add_action( ‘pre_get_posts’, ‘my_admin_pre_get_posts’ ); function my_admin_pre_get_posts( $q ) { // Check whether the filter was clicked. if ( isset( $_GET[‘post_parent’] ) ) { $screen = is_admin() ? get_current_screen() : null; // And that it’s the edit pages page. if ( $screen && ‘edit-page’ === … Read more
Please try like if ( is_front_page() || is_home() ) { //IF HOME PAGE } if ( is_singular(‘YOUR-CUSTOM-POST-TYPE-HERE’) ) { // FOR SINGLE PAGE STUFF } Please make sure you have to replace YOUR-CUSTOM-POST-TYPE-HERE with your Custom post type. Please let me know if any query. Thanks!
In order to add a new value and keep the previous values, you need to use add_post_meta() instead of update_post_meta(): $post_id = get_the_ID(); $new_post_desc=”the new value here”; // add_post_meta() add a new field with the same name // and keeps previous values on the database add_post_meta( $post_id, ‘post_desc’, $new_post_desc ); Then, you can use get_post_custom_values() … Read more
You have already mentioned the function wp_title(). Right before outputting the title, it passes its value through the filter wp_title, which can be used here to prepend with additional information. add_filter(‘wp_title’, ‘WPSE_20181106_prepend_title’, 10, 3); function WPSE_20181106_prepend_title($title, $sep, $seplocation) { // not a single post if (!is_singular(‘post’)) { return $title; } // IDs of categories that … Read more
WP_Query is not a general-purpose method for querying the database. It’s specifically designed for querying posts with the intention to loop over them and output templates for them. If you just want arbitrary data from the wp_posts table, then you can just write SQL and use the $wpdb object to run it: $query = $wpdb->prepare( … Read more
How are you associating users to a post? If you meant users as post authors you can try pre_get_posts hook. function user_author_pre_get_posts( $query ) { $user_id = get_current_user_id(); // Get logged in user ID or pass specific user ID here if ( ( $query->is_author() || $query->is_category() ) && $query->is_main_query() ) { $query->set( ‘author__in’, $user_id ); … Read more
Finally I’ve decided to use custom sql query with get_results method. $query = “SELECT SQL_CALC_FOUND_ROWS p.*, IFNULL(m2.meta_value, p.post_date_gmt) as zen_date FROM {$wpdb->posts} p LEFT JOIN {$wpdb->postmeta} m1 ON (p.ID = m1.post_id AND m1.meta_key = ‘is-exclude’) LEFT JOIN {$wpdb->postmeta} m2 ON (p.ID = m2.post_id AND m2.meta_key = ‘is-push’) WHERE p.post_type=”post” AND p.post_status=”publish” AND m1.post_id IS NULL … Read more
you’re using commas as concatenators you’re echoing the_title() and the_post_thumbnail() (use get if you’re echoing) your the_post() was at the bottom <div class=”Jobs”> <?php if(have_posts()) { while (have_posts()) { the_post(); echo'<div class=”info_Job”>’; echo ‘<h2>’.get_the_title().'</h2>’; echo get_the_post_thumbnail().'</div>’; } } ?> </div> If you don’t want to use get but directly output do this instead: <div class=”Jobs”> … Read more
Here is a plugin which does exactly what I asked for and it is very simple to use. https://github.com/scribu/wp-posts-to-posts