Wordpress Custom Post Type - Post Attribute: Template. Template shows up and saves on the back end, but the default theme file is being rendered

Edit: Now I've found that this is Hybrid Core, and apparently the template hierarchy is different. I still haven't solved my problem below though. In addition to the title. My thinking is that if I am able to select a template in the backend, it should honor that selection. It doesn't change though. I've tested the other template file in place of the default, and it works. This is the function to add my custom post type. This works just …
Category: Web

get_the_post_thumbnail() title and alt attributes not displaying

I am attempting to display 'alt' and 'title' attributes on a post thumbnail image, but the only attribute that actually displays as passed is 'class'. 'alt' and 'title' are missing. Any ideas what could be the cause? $thumbnail_id = get_post_thumbnail_id( ); $image_alt = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true); echo $image_alt; //correct alt attribute text echo get_the_post_thumbnail($post->ID, 'post-thumbnail', ['class' => 'classTest'] ); //works echo get_the_post_thumbnail($post->ID, 'post-thumbnail', ['alt' => 'altTest'] ); //doesn't work echo get_the_post_thumbnail($post->ID, 'post-thumbnail', ['title' => 'titleTest'] ); //doesn't work <img width="940" …
Category: Web

Submitting product attributes via Ninja Forms wordpress?

I have a wordpress website selling products. On the product page there is a button “Ask a question”, through which a pop-up form created on the basis of the “Ninja forms” plugin opens. There are fields for input, when they are filled in, a letter is sent to the mail. But the customer wants the attributes of the product (size, material, etc.), through which the user asks the question, to come as well. Attributes are displayed on the product page …
Category: Web

Automatic duplicate/copy of post to a related page in WordPress

I have a website about introducing softwares and apps. I created pages and so menus (named by categories). I set my WordPress setting homepage to latest posts. I create posts and give them categories and tags. I like to have the option to automatically create a copy of content of a post in related page, in which this relation might be its category? Is there such possibility inside WP or some free plugins? Thanks.
Category: Web

Why is a renamed custom template file still showing up in the template dropdown menu?

I recently renamed a custom template file, changing it from template-programs.php to template-program-schedule.php. In my template dropdown menu, Program Schedule shows up as expected, but Programs is also still there. I have cleared all caches and hard refreshed the browser, but it still shows up. I've tested the template dropdown functionality by creating dummy template files, which always appear in the dropdown menu after creation and then disappear as expected when deleted, but Programs remains in the list. I searched …
Category: Web

Change Order of Admin Posts Depending on Meta

In my Admin Panel I have a custom post type of posts - with page attributes to define order. Is there "easy" way of changing how the admin panel pulls posts so I can reorder them? Page Attributes define order and parents. My Custom Post Type isn't a page but it still supports Page Attributes because I want to order them in a meaningful way. Currently in Wordpress Admin Panel when using Custom Post Types and Page Attributes, the Admin …
Category: Web

An excluded 'ghost' page is crashing my permalink

I am a SEO intern, and I'm having a problem with a wordpress page that I have to optimize. So, I would like to make a better site structure, but when I am going to configure the permalink of the ascending page in the page attribute, the site crash. Here is the video of the crash https://drive.google.com/file/d/1Lbth0xFeh_GIqDyjpWP0FfU3tV6_WT7v/view And the ascending page that appears "/Wolf/" doesn't exist in any of the trash or drafts of the wordpress blog Thanks, this is …
Category: Web

How to disable Page Attributes dropdown in wp-admin

As discussed at WordPress admin screen very slow / timing out when editing or adding a new page/custom post I am having a similar issue on a WP site containing 7,784 pages. Edit screens are slow loading due to the rendering of all 7k pages in the source code for the Page Attributes dropdown menu. Besides editing core, there must be a better way to deal with this. Seems like a flaw to render all pages on the edit screen. …
Category: Web

Sort CPT archive by order prevents sorting in admin

I've activated the Order feature for my 'portfolio' CPT and have managed to arrange my 'portfolio' posts according to respective Order values I've provided. Unfortunately, I've found that this code locks the order that 'portfolio' items are displayed in admin; I can't toggle the Title ascending/descending feature nor am I able to sort this list by Date. My goal is to display these 'portfolio' items on the live site using the Order feature but I'd still like to be able …
Category: Web

Custom template not working for existing pages

I was playing around with using a custom template per page. (Because I need to load different post types per page). When creating a new page, and link my custom template to it via Page Attributes, it all works. I see on that new page the specific template applied. Now, when selecting my specific the template on an existing page (= my production pages), it doesn't work... It just shows the content of the index.php. I've been searching hours on …
Category: Web

How to add data- attribute to <body> tag

I need to add a data- attribute with a user-supplied value (via custom fields) to the tag of each page. I tried editing header.php as such &lt;body &lt;?php astra_schema_body(); ?&gt; &lt;?php bene_body_class(); ?&gt; data-myAttr=&quot;&lt;?php get_post_meta(get_the_id(),'my_attr')[0] ?&gt;&quot;&gt; but when I load the page, the attribute does not show up. I'm guessing something the theme strips out all unknown attributes? Is there a filter I can use to add it in via functions.php?
Category: Web

How can I set different html lang attribute for different countries?

My WordPress theme header.php html language attitude &lt;!DOCTYPE html&gt; &lt;html &lt;?php language_attributes(); ?&gt;&gt; All page html language attitude : &lt;html lang=&quot;en-US&quot;&gt; But I have some pages for different countries. I want to use different html lang attitude code for each country page with single header.php For example: English page language attitude : &lt;html lang=&quot;en&quot;&gt; Portuguese page language attitude : &lt;html lang=&quot;pt&quot;&gt; Spanish page language attitude : &lt;html lang=&quot;es&quot;&gt; Indonesian page language attitude : &lt;html lang=&quot;id&quot;&gt; Vietnamese page language attitude : …
Category: Web

Remove Header and style.css from Specific Post template

I want to add some custom code so I've created a custom post file with the following content. &lt;?php /* * Template Name: Custom App * Template Post Type: post, page, product */ ?&gt; &lt;?php get_header(); ?&gt; App Code here... I want to remove the header element &lt;header id="header" class="main-header"&gt; and style.css from the custom post using function.php file. I want to keep &lt;?php get_header(); ?&gt; because of yoast SEO and some analytics scripts. I don't want to hide the …
Category: Web

Custom post-type working except for Selecting page-parent

I created a custom post type in functions.php with these values (amongst others): 'hierarchical' =&gt; true, 'supports' =&gt; array( 'title', 'thumbnail', 'revisions', 'page-attributes'), 'capability_type' =&gt; 'page', I understood this should be the bits needed to get page attributes to offer parent page as a dropdown to make it a child of another page, however all that shows in page attributes is Order with a number box. Have I missed something to get this working? I assume also that if this …
Category: Web

Force a specific template as default

[ EDIT: I'm using Chaplin theme as the parent theme ] I'm working on a child theme and I need to set a specific template as default for all posts (there's no custom post types, just regular posts). Just to be clear: I need that every time a user adds a new post, &quot;My custom template&quot; is picked instead of the &quot;Default template&quot;. I asked the developer of the original theme for a suggestion and he pointed me to this …
Category: Web

How to convert the WordPress meta box Page Attributes->Page Template dropdown to radio buttons?

I would like to be able to change the Page Attribute "Templates" dropdown to radio buttons, to allow me to have corresponding thumbnails next to them. I have already removed and replaced the Page Attributes meta box on functions.php, as per below: add_action( 'add_meta_boxes', 'wpse44966_add_meta_box' ); function wpse44966_add_meta_box( $post_type ){ remove_meta_box( 'pageparentdiv', 'page', 'side'); add_meta_box( 'wpse44966-meta-box', 'page' == $post_type ? __('Page Style Templates') : __('Attributes'), 'wpse44966_meta_box_cb', 'page', 'side', 'low'); } I am then able to call back the "Templates" dropdown …
Category: Web

How to list all WC products by their attributes values?

I wanted to get some advice on how to list all my inventory attributes values. I have this simple code that will output the products as plain text, But instead of the_title(); I want a list of all products by their attribute's values. So, if a product has attribute carat it will be listed as follows: carat 0.32 0.41 2.3 3.3 A product has attribute color and another product has attribute carat and they will be listed as red 0.32 …
Category: Web

About

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