Need to add a post’s featured image to a section on the frontpage

It looks like I will need to create custom PHP code for this and either add it to my includes directory within a custom PHP file, or to the functions.php file. I need the ability to use a featured image in a post and be able to also dynamically display that same image in a gallery on the frontpage. I am not a PHP master by any means, but I know a bit to get around. My guess is I …
Category: Web

Wordpress : how to allow a user to post a module that leads any visitor to a product page ? (front end)

My current WP configuration Theme used : DIVI Extensions in place : Almost none Name of the host : Infomaniak Site address : not yet created Problem(s) encountered : Hello, First of all, thank you to all those who will take the time to read this post and to give me their help. I'm currently starting a website that I'm very interested in and there is one feature in particular that I don't really know how to implement. I will …
Category: Web

How to filter get previous post function by meta value DESC and post date DESC?

My loop displays featured posts and then posts in reverse chronological order. However when I use <?php echo get_previous_post(); ?> it grabs posts in reverse chronological order. How do I add a filter to the previous post function similiar to this but instead filter by an array like this: 'orderby' => array( 'meta_value' => 'DESC', 'date' => 'DESC') ? Code: UPDATE: Cleaned up index.php loop after help from @sMyles and @JackJohansson Index.php loop: $args = array( 'posts_per_page' => - 1, …
Category: Web

How to get relative URL of medium sized featured image?

How to show featured image (medium sized) relative URL (relative to the website root)? I need something like this: uploads/214/07/image-600x400.png I tried with this: if ( has_post_thumbnail()) { $medium_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium'); echo $medium_image_url[0]; } It works fine, I get path of medium sized featured image, but with domain name too, and I need it without domain name. Also I tried like this: global $wpdb; $the_thumbnail_id = get_post_thumbnail_id($post->ID); $the_thumbnail_name = $wpdb->get_var( "SELECT meta_value FROM $wpdb->postmeta WHERE post_id = '$the_thumbnail_id' …
Category: Web

Display featured products through custom loop in woocommerce on template page

I would like to display 6 featured products from my woocommerce store on my home-page.php template. After some researched I found that the right way to do this was through a custom loop,( I do not wish to use shortcodes because I would like to add additional classes for styling etc. ) I also found that the key that woocommerce uses for the featured products is '_featured'. I put together the code below to display any products that I chose …
Category: Web

Display Featured Post by Categories and Avoid duplicated posts

I'm learning Wordpress development on Udemy and currently developing a theme. I haven't added any custom taxonomy but just using the "Post" and "Categories". Found a tutorial of how to add "Featured Posts" I have created 3 categories, and I want to display featured post of that category when loads the category.php and avoid duplicated post. The issue now is that the featured post (Ex. Category 1) is displaying on all category pages. Here is my code: <?php $args = …
Category: Web

Get attachment thumbnail from get_posts function

How do I get the id of the most recent wordpress audio media upload. The reason for this is that I want to use audio cover images/ featured images as a post featured image. Do I need to retrieve the ID of the thumbnail in the audio. I tried the code below but it returned error $attachments = get_posts( array( 'post_type' => 'attachment', 'posts_per_page' => 1, 'post_status' => null, 'post_mime_type' => 'audio' ) ); foreach ( $attachments as $attachment ) …
Category: Web

Remove any product that is featured from regular display loop [WooCommerce]

I have set up a custom loop to display featured products at the top of their relevant category pages. but now I would like to go about removing featured products from the regular loop below, which is using the standard woocommerce code to display products, Any help would be greatly appreciated http://onthesquareauctions.com/index.php/product-category/emporium/furniture/chairs-emporium/
Category: Web

How to list blog post from subdirectory wordpress install to the main site

I have decided to separate my main website and my blog with different Wordpress installs. I've installed my blog in the subdirectory (/blog/ folder) and my main Wordpress is only contained homepage and pages related to my business. The problem is, is it possible to create a section on my main website that lists 4 latest posts from my blog that are installed in the subdirectory? I have searched all over the internet for the solution, but I've found nothing. …
Category: Web

How to mark only one post as Featured post?

Am working on a blog page and I want to have a featured post as a banner. I have no idea how can I make only one post can be marked as the "Featured" so if another post is marked as "Featured" it removes the old post from showing as featured. I've tried using ACF (Advance Custom Field) checkbox to mark featured posts but my approach is incorrect. Here is my code. <?php global $post; $myposts = get_posts( array( 'posts_per_page' …
Category: Web

How to display the featured post on the category page?

I have created a feature post check box on the post page. Now what I am doing is if any user-selected that checkbox then I have to show that post on the category page. I tried below code but it's not displaying. Code is to add feature post on post // add feature post on post page function register_post_assets(){ add_meta_box('featured-post', __('Featured Post'), 'add_featured_meta_box', 'post', 'advanced', 'high'); } add_action('admin_init', 'register_post_assets', 1); function add_featured_meta_box($post){ $featured = get_post_meta($post->ID, '_featured-post', true); echo "<label for='_featured-post'>".__('Feature …
Category: Web

Featured images duplicating and replacing next image

Took over a project, and one of the errors is the featured images (and certain others rendered in a similar way) are duplicating themselves and replacing the next image thumbnail. <a href="<?php echo get_permalink(); ?>" class="snack__thumb snack__thumb--featured" style="background-image:url('<?php echo get_the_post_thumbnail_url( $post->ID, 'medium' ); ?>');"> <?php if (has_category('whitepaper')) { ?> <div class="snack__banner"><span>whitepaper</span></div> <?php } ?> I've read that not ending a loop with something like wp_reset_postdata(); can cause this type of error however I haven't been able to get it solved. …
Category: Web

Feature Image Showing Too Big

My feature images keeping showing up too large, I have tried to resize the images and re-upload but they are still showing up too big. I have tried to put in CSS code and gone onto Media setttings but haven't had much luck yet. Can anyone help please?
Category: Web

Gutenberg editor get post featured image by id

How can I show a post featured image by post id in gutenberg editor? I have a slider with latest posts and when I iterate through over posts I would like to show the post featured image as well. Here is my example snippet const cards = displayPosts.map( ( post, i ) => { console.log(post.featured_media) return(<div className="card" key={i}> <div className="card-image"> <div className="image is-4by3"> <PostFeaturedImage currentPostId = {post.id} featuredImageId = {post.featured_media} /> <div className="news__post-title"> <div className="title is-5"> <a href={ post.link } …
Category: Web

How to change featured content to a different tag in Wordpress Twenty Fourteen?

In twenty fourteen theme, we’d like to know how to change the features content tag. Currently it’s set as featured. Now, we would like to know how to code this for different page templates. We notice in page.php there is a piece of code calling the template part featured-content. <?php if ( is_front_page() && twentyfourteen_has_featured_posts() ) { // Include the featured content template. get_template_part( 'featured-content' ); } ?> From our understanding this calls the file featured-content.php. In this file, is …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.