The Stack Overflow podcast is back! Listen to an interview with our new CEO.

All Questions

Filter by
Sorted by
Tagged with
0
votes
1answer
29 views

WordPress wp_get_current_user returning blank values until refresh

I'm developing a site in WordPress and creating my own theme. As part of the theme, I have a custom user login. When a user logs in, the form action directs back to itself and in the header of the ...
1
vote
1answer
26 views

Highlight “Show all” item in wp_list_categories

I use wp_list_categories to display category filters on post archives. I can use current_category param to set current category - and such item will get addition class current-cat. I can even omit ...
1
vote
2answers
2k views

How to modify an image block in Gutenberg WordPress 5?

Adding images to a post with the block editor: produces the code figure of: <figure class="wp-block-image"> <img src="http://localhost:8888/time.png" alt="alt text" class="wp-image-1391"...
0
votes
0answers
83 views

Alternative solution for script_loader_tag?

Theme check plugin gives me this error Found script_loader_tag in the file functions.php. Do not remove core functionality. I have used it to defer scripts function add_defer_attribute($tag, $...
6
votes
1answer
446 views

Edit srcset and sizes attributes in Gutenberg image, cover and gallery - blocks

I am looking for a way to adress the responsive srcset and sizes attributes on Gutenberg image blocks - like image, cover and gallery. Usually one would do this with the '...
0
votes
0answers
27 views

wp_nav_menu() filter - preg_replace value returned wrong

I'm having an issue where the filter I've added to wp_nav_menu() is adding code to the second level of the navigation. How can I change the filter or the preg_replace code in a way that only adds it ...
0
votes
0answers
23 views

What is the recommended way to save errors / warnings / user messages from actions / filters for custom display in the frontend?

This is a very basic question and there are a lot of solutions to it - however what is the recommended (or at least a good) way? Problem statement: While processing a request to a WordPress project ...
0
votes
0answers
45 views

Remove action added in plugin class from theme

I am trying to remove action that is added via plugin in my theme. The below plugin class creates a portfolio page template but I don't want this page template in my theme. Is there any way to unhook ...
1
vote
1answer
90 views

When trying to override plugin's function by theme, my filter executes two times, I want it to run only a single time

Here's plugin function: function dokan_get_admin_commission_by($order, $seller_id) { $saved_admin_fee = get_post_meta(dokan_get_prop($order, 'id') , '_dokan_admin_fee', true); if ($...
1
vote
1answer
532 views

Wordpress nav_menu_css_class theme filter is not being called

I'm having problems getting a filter to work. I'm trying to add a class to each <li> element of a menu. This is on my theme's functions.php file: /** * Adds custom classes to the items in the ...
1
vote
0answers
38 views

How to change the post type a theme shows by default?

I have a theme that displays the normal post_type post, but want it to take the post from my custom post type my_posts_custom. I don't want to make this change manually on the theme. Are there any ...
1
vote
1answer
289 views

Current category link filter

In my theme i have an archive template for a taxonomy (taxonomy-cat_projet.php), in this template a have a list of these taxonomies links to allow users to select a taxonomy. Here is the code i'm ...
0
votes
1answer
32 views

Alt header logo and link for specific pages

Building a WP site where two parent categories are styled to look like two distinct sections/sites. I'm using the custom logo (set in Appearance/Customise) and using the function below I can ...
0
votes
2answers
49 views

Modify available templates (in dropdown)

I'm developing a WordPress theme with several templates. One template is called "Tabs". If a page with this template assigned has children pages, parts of their contents are shown in tabs on the ...
0
votes
1answer
1k views

Remove External Links from WordPress posts Using add_filter() in Theme functions.php

We have been searching high an low for a plugin, code sample or example of how to remove all external links at the theme filter level but can't seem to find anything online. We want to keep the ...
-1
votes
1answer
186 views

append code after the_content not working

Goal: Add pagination below single post pages. Code function add_pagin( $content ) { if ( is_singular('post') ) { $content .= previous_post_link() . next_post_link(); } return $...
2
votes
1answer
897 views

wp_get_attachment_image_attributes not working for me

I've distilled this example down to its most basic functionality on my local site and it still has no effect, no matter which attribute I choose to change. Here is the developer page for the filter, ...
1
vote
1answer
451 views

What's the difference between hooks, filters and actions? [duplicate]

It seems like the terms hooks, filters and actions are used interchangeably. What's the difference between them? What do they do? How do I use them?
0
votes
2answers
26 views

Unique design inside a specific category's url

I been modifying a WordPress theme, and for some specific pages that need a specific design I placed a php file named page-specific-url.php where specific-url is the page I want to show. The problem ...
0
votes
1answer
53 views

How to rotate every letter in a title

I was wondering how to rotate every letter in a title. You can rotate every letter in a word with <span class="slant">A</span class="slant"> <span class="slant">c</span class="...
0
votes
1answer
281 views

WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages

Can you WordPress Gurus please help! I have tried adding some code suggestions found on the web to my style.css file in my theme folder to solve my problems but they have no effect. I've have so far ...
4
votes
2answers
691 views

Display a different theme for not logged-in users

Based on answers like this one, I made a small plugin to display a theme displaying a "Coming soon" theme, whilst our team of editors can fill in the final theme. It worked yesterday, but today, even ...
0
votes
1answer
473 views

Make a custom field in admin post.php read only

How I make a custom field (which can be enabled from the screen options) in the post edit page read only and not editable.
0
votes
1answer
84 views

Caption Shortcode: what filter to change the image size?

Doing a huge overhaul of my website mainly for page load performance, I want to filter the caption shortcode in the_content to load the thumbnail version of the image if wp_is_mobile() returns true. ...
0
votes
1answer
56 views

Custom theme: adding unwanted <p> tags in the content

I've built a custom theme and it works fine apart from WordPress injecting unwanted <p> tags on the page before the post loop starts. On top of that, it adds the word 'Save' eg: <p>Save<...
1
vote
1answer
42 views

Wordpress taxonomy and archive custom class

I want to add custom class. But archive and custom taxonomy both are executed at the same time. When I want to add class to taxonomy page, the archive class is also added. I understand taxonomy is ...
1
vote
0answers
214 views

Change file name from wp_generate_attachment_metadata

I'm pretty new and just have a hang on how wordpress data flows internal. I am confronted with applying a b/w filter on upload. no problem. I found the wp_generate_attachment_metadata filter and ...
0
votes
1answer
288 views

tiny_mce_before_init: 'exact' => true has no effect

For a custom theme, the editors want to be able to select three different font sizes in the post editor. I thought about using a standard font size plus defining two extra classes: <p class="...
12
votes
4answers
5k views

Issues with title-tag and document_title_parts

Wordpress version 4.5.1 I'm trying to dynamically update page titles on a particular template. After lots of digging and learning about the wp_title() changes, I'm attempting to use ...
0
votes
1answer
604 views

How to add aria role and schema markup to custom walker container

Edit: after doing some research I've found that in the wp_nav_menu function uses the following code to display the containers value. if ( $args->container ) { /** * Filter the list of ...
1
vote
3answers
3k views

Menu item added in wp_nav_menu_items filter is never highlighted

In a Twenty Thirteen child theme I append a menu item (a link to /player-number page template, where the number is different for each user and represents her or his id in a game database) using the ...
0
votes
1answer
82 views

Hook in parent theme Menu function

Trying to modify Parent Menus function on child theme, the original function is: function original_theme_menus() { $menus = array( 'top' => __( 'Top Menu', 'theme-domain' ), ...
0
votes
1answer
1k views

How do I remove p tag *insertions*? Disabling `wpautop` removes manual tags

I am trying to post static pages with HTML content. So I need to disable wpautop, but when I do this my content is stripped of all <p> tags it has. I remove the wpautop filter from my header....
0
votes
1answer
615 views

How to add custom nav_menu_css_class to certain menu only?

I want to add a custom CSS class to menu items. So far, I got it working by using the filter hook nav_menu_css_class. However, I want to add this class to items of a specific menu only. So, how must ...
0
votes
1answer
104 views

Passing variable in hooks and filter

I was trying to pass variables in filtes. This works perfectly for me. class my_class { function my_class() { add_filter('wp_list_categories', array(&$this,'cat_count_span')); } function ...
1
vote
2answers
130 views

Simple way to get two language WP site

I am trying to make a site with two languages. I was looking for a solution and didn't find a simple how-to answer. Also, I prefer not to use plugins when it is possible. What I'm trying to do: 1) ...
2
votes
1answer
463 views

customizing the_password_form filter

I'm trying to customize the_password_form to integrate it with bootstrap inline-forms with an add_filter() function: function custom_passowrd_form ( $form ) { global $post; $label = 'pwbox-'.( empty( ...
0
votes
2answers
84 views

How to manipulate wordpress template tags' output

take the_category() as an example: Here is the output of the_category function in the wordpress loop: <ul class="post-categories"> <li> <a href="http://example....
1
vote
1answer
94 views

Wordpress custom taxonomy check box to dropdown

Hi my custom taxonomy name is country.In this A is a country, a-sub1,a-sub2 are states under A. b-sub1,b-sub2 are state under Country B. Now i need to display the country list(parent) box and state ...
0
votes
1answer
63 views

Wordpress permalink setting

I have a doubt. If book is my custom post type, language is my taxonomy, english is the item in taxonomy , Harrypotter is new post in book with txonomy english. Then how i get the url structure like ...
0
votes
1answer
388 views

what is do_action(); in wordpress? [duplicate]

Sorry for making duplicate Topic but it is very important to me because i don't understand this topic by looking other related topics. Actually i am in process to build a WordPress theme and i am ...
0
votes
1answer
118 views

Add rel to all images in a post

I want to add a rel to all images in a post. I am trying following filter but it will wrap only the images which are in the gallery. It does not wrap the images which are added individually without ...
1
vote
3answers
1k views

Show excerpt for only first post in query

I'd like to only show the excerpt for the first post in my main query. I was wondering the best way to approach this. What I have tried so far is: Making a custom homepage and using two queries, one ...
0
votes
1answer
717 views

Allow tags and attributes in post and pages content

I am trying to allow the "onclick" attribute on links as well as some html tags such as iframe to the content displayed in posts and pages. In my theme's functions.php file, I tried removing ...
1
vote
0answers
58 views

Filter categories used with Custom Structure Permalink

I'm using a "Custom Structure" permalink setting: http://mysite.com/%category%/%postname%/ However, when the post belongs to uncategorized, or to more than one category, this produces unwanted URL ...
0
votes
0answers
119 views

Suppress the_content filter in a nested loop

I have some layout changes that are being applied to the_content. I need to do one of two things, but neither is working as expected... either: Pass data to the filter so that it knows if it is a "...
0
votes
1answer
105 views

How to conditionally add a wp_filter

I have a WP filter I created that I only want to run on certain menu items. I am attempting to use - function add_nav_class($output) { $output= preg_replace('/<a/', '<a class="lsbb"', $output,...
0
votes
2answers
154 views

Filter didn't work on content class (hybrid_post_attributes)

I'm developing my new theme using Hybrid core framework and trying to add my class item on hybrid_post_attributes generated class using filter with this code. add_filter( 'hybrid_post_attributes', ...
0
votes
1answer
181 views

How to set default values for edit_post_link() in my theme?

How do I set default values for the edit_post_link function in my theme? I'd like to change the 'Edit This' string to a custom value, but specify this only once, so I can use instead of everywhere. ...
0
votes
1answer
110 views

How to disable thumbnail filter for a specific template part or image size?

I am filtering post_thumbnail_html in my theme to modify the output of my image tags. I have one template part that I would like this filter not to apply to. It uses an image-size that is used no were ...