I added the following to my functions.php: add_action('pre_get_posts', 'keyl_get_emp_posts'); function keyl_get_emp_posts($query) { if ($query->is_main_query()) $query->set('post_type', 'employee'); } and so far it's effectively filtering out the search results. The default widgets Recent Posts and Recent Comments aren't budging, though. What gives?
I've added a page template that is my new home page and I would like to be able simply list the last 5 blog entries. My home page currently looks like... <?php /** * This file controls the layout of your homepage * * @package WordPress * @subpackage Pytheas WordPress Theme * Template Name: Custom Home */ get_header(); ?> <?php get_template_part('content','slider'); ?> <div id="primary" class="content-area span_16 col clr clr-margin"> <div id="content" class="site-content" role="main"> <?php $wp_query = new WP_Query( array( 'post_type' …
I have 6 related posts by tag in every post. But some tags have only 2 or 3 posts. So in these posts, related posts section shows only 2 or 3 post. I want to complete related posts (if not 6) with the new posts. I tried many codes but if tags have 2 posts, than related posts show 2 post only. Can I add new posts to complete to 6? Or can I display recent post order by same …
I spent most of the day reviewing past questions and answers and have not found anything that addresses what I am trying to do. Maybe I didn't word my search correctly. Lets say I have a category of posts for documents that reflect current committee members. I can create a WP menu item for a specific post with Wordpress However, users can submit new posts using the USP Pro plugin. Now the menu item needs to point to the most …
Since my homepage is a static page, WordPress shows a Recent Posts tab with the HTML ID "front-page-recent-posts". This seems to be a unique widget, and I cannot find a way to edit its settings. Can someone please suggest a way how I can edit the settings so that it shows a small 10-20 word excerpt of my blog posts? Currently, it looks like this:
I'm using MailChimp Campaigns Plugin where it imports all Mailchimp campaigns as a custom post type on the website. The app works perfectly however I'm modifying the process to import recent posts only to avoid any post modification to be overwritten. The import() function works as following: /** * Actually do the import of Mailchimp campaigns. */ public function import() { if ($this->is_error) { return; } $x = 0; $campaigns = $this->getCampaigns(); foreach ($campaigns as $i => $campaign) { try …
hello so i want to add on wordpress widgets title= before the href link to widget_recent_entries and widget_pages the title= so how can i do that ? it have an widget-title but not the title= to alla the links any php code to add this because if i add this to the php files of wp-includes it will be remove in another update ? thanks a lot widget_recent_entries and widget_pages
It would be great to make a single DB request but I don't know how to do that either. I have this code and it works but I want to change it to be more efficient: $cs = get_categories(array( 'orderby' => 'name', 'order' => "ASC", )); $params = array( 'last_five_articles' => array() ); foreach ($cs as $c) { $rp = wp_get_recent_posts(array( 'numberposts' => 5, 'post_status' => 'publish', 'category' => $c->term_id )); foreach ($rp as $idx => $crt) { $rp[$idx]["post_content"] = …
Hi I am needing some help trying to add the recent post excerpt to the bottom left div of my webpage. below is the piece of code that I'm having problems with in-between the p tags. I can display the post title and the ID, But cant get the recent post content or the recent post excerpt. <!-- //start --> <h2>Recent Post</h2> <div class="recent-post-holder"> <div class="recent-image-holder"><img class="recent-image" src="images/feeding.jpg" alt=""></div> <?php $args = array( 'numberposts' => '1' ); $recent_posts = wp_get_recent_posts( …
Using Elementor. I have a question, displaying users by roles (subscriber) on page with different user meta fields like image, username and button. Subscribers can add 1 property listing. Now I want when any public user click on button it should go to property listing details as he a is post author of this listing. How can I set up permalink it should go to user listing details with permalink. If that user has a publish posts. Does it possible …
How to add recents posts to the menu? Entries with pictures. "Menu-item-object-custom" items in a div container? What I have now is: header.php wp_nav_menu( array( 'theme_location' => 'menu-1', 'menu_id' => 'primary-menu', 'menu_class' => 'display_lasts_ten_posts_for_categories_menu_item', 'walker' => new WPSE_78121_Sublevel_Walker, ) ); functions.php add_filter('wp_get_nav_menu_items','display_lasts_ten_posts_for_categories_menu_item',10,3); function display_lasts_ten_posts_for_categories_menu_item( $items, $menu, $args ) { $menu_order = count($items); $child_items = array(); foreach ( $items as $item ) { if ( 'category' != $item->object || ('category' == $item->object && get_category_children($item->object_id)) ) continue; $category_ten_last_posts = array( 'numberposts' => …
I used gutenberg layout method with wordpress editor to call recent posts. Wordpress automatically generated this HTML structure. <ul class="wp-block-latest-posts__list has-dates wp-block-latest-posts"> <li> <div class="wp-block-latest-posts__featured-image"> <img loading="lazy" width="1024" height="663" src="" alt="" class="wp-image-73" srcset="" sizes="(max-width: 1024px) 100vw, 1024px"> </div> <a href="">SOME TEXT</a> <time datetime="2021-05-08T17:21:16+00:00" class="wp-block-latest-posts__post-date">May 8, 2021</time> <div class="wp-block-latest-posts__post-excerpt">SOME TEXT</div> </li> </ul> Now I need to group anchor, time and the last div tag in another div tag for my CSS design. Problem is I do not know how to edit …
This works well on archive.php, but not working on the homepage. For some reason, the first statement doesn't get applied: if a post is in Members category and user is not logged in, it's supposed to show a default placeholder image, but instead it's still showing the actual post thumbnail. <?php if (!is_user_logged_in() && in_category('members')) { ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <img src="<?php bloginfo('template_directory'); ?>/img/default-login.jpg" alt="<?php the_title(); ?>" /> </a> <?php } else if (is_user_logged_in() || !in_category('members')) …
I have a page marked as the Posts page that lists most recent blog posts. It is at path /blog. I want to know when the user is on this page so that I can display a list of categories of blog posts at the beginning of the page. I already did this in singular.php and in the rest of the cases in index.php. For me is_home() returns true when on the landing page. And I use its behavior in …
I am using the code below to generate posts created in the last 48 hours. function filter_where($where = '') { $where .= " AND post_date > '" . date('Y-m-d', strtotime('-2 days')) . "'"; return $where; } add_filter('posts_where', 'filter_where'); But I also want to get the posts modified in the last 48 hours. Even if their creation date is older. Does anyone know how to do this? I'd appreciate your help...
I want to display the Recent Posts Widget title on a page, however I could not find a solution yet. I dont want to display the recent posts on the page only the title of the most recent posts widget, given by user. Is there a simple way to do that? Thank you in advance
I have author pages for each author and I want to see all of their comments (or all of their recent comments) if I click on their nickname. How can I do this? I tried the beneath code, but that does not show the unique comments per user... It just outputs all recent comments from everyone combined, but I don't want that. <?php $author_email = get_the_author_meta( 'user_email' ); $args = array( 'author_email' => $author_email, 'number' => '10' ); $comments = …
I want to show 8 recent products from multiple authors on the frontpage. Need to show 1 recent product per author. Currently i'm using basic wp query to show recent 8 products. $args = array ( 'post_type' => array( 'product' ), 'posts_per_page' => '8', 'order' => 'DESC', 'orderby' => 'date', ); // The Query $query = new WP_Query( $args ); What's the best way to achieve this?
I'm trying to feed posts in my blog page with a WP bakery widget. I have 8 posts published, but when I hit load more button it loads first 3 posts instead of those in the end. Attaching screenshots, also I'm not sure what else info do I need to share, so please tell me if some additional details needed.