qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
235,599
<p>I'm trying to have a Bootsrap carousel to display my post -</p> <p>They are being display, However, it doesn't work correctly. It doesn't slide basically....</p> <p>Here is the live example:</p> <p><a href="http://latitudesadventure.co.uk/novocore/dusty-oak/" rel="nofollow">http://latitudesadventure.co.uk/novocor...
[ { "answer_id": 235751, "author": "pallavi", "author_id": 96726, "author_profile": "https://wordpress.stackexchange.com/users/96726", "pm_score": 1, "selected": false, "text": "<p>You have added active class in all slides. Due to this all slides is displaying. You have to add active class...
2016/08/10
[ "https://wordpress.stackexchange.com/questions/235599", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54146/" ]
I'm trying to have a Bootsrap carousel to display my post - They are being display, However, it doesn't work correctly. It doesn't slide basically.... Here is the live example: <http://latitudesadventure.co.uk/novocore/dusty-oak/> I'm using the code below: ``` <div id="myCarousel" class="carousel slide"> <!-- Ca...
You have added active class in all slides. Due to this all slides is displaying. You have to add active class to first slides only. Check below bootstrap slider code- ``` <div class="carousel-inner" role="listbox"> <div class="item active"> <img src="..." alt="..."> <div class="carousel-caption"> ...
235,602
<p>I want to end up with url structure for galleries like the one below ; </p> <p><a href="http://myurl.com/gallery-name/gallery-item-name" rel="nofollow">http://myurl.com/gallery-name/gallery-item-name</a></p> <p>as you see there will be two variables. </p> <p>I separated templates like content-default and content-...
[ { "answer_id": 235751, "author": "pallavi", "author_id": 96726, "author_profile": "https://wordpress.stackexchange.com/users/96726", "pm_score": 1, "selected": false, "text": "<p>You have added active class in all slides. Due to this all slides is displaying. You have to add active class...
2016/08/10
[ "https://wordpress.stackexchange.com/questions/235602", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98843/" ]
I want to end up with url structure for galleries like the one below ; <http://myurl.com/gallery-name/gallery-item-name> as you see there will be two variables. I separated templates like content-default and content-gallery.. So far it's OK. But what should i do to open a single gallery element page when user goes...
You have added active class in all slides. Due to this all slides is displaying. You have to add active class to first slides only. Check below bootstrap slider code- ``` <div class="carousel-inner" role="listbox"> <div class="item active"> <img src="..." alt="..."> <div class="carousel-caption"> ...
235,605
<p>After each menu item, I want to add the page excerpt underneath it.</p> <p>So if i have a menu that looks like this:</p> <ul> <li>Home</li> <li>About</li> <li>Contact</li> </ul> <p>I want to get the page excerpt into the menu like this:</p> <ul> <li>Home <ul> <li>This is the home page excerpt</li> </ul></li> <l...
[ { "answer_id": 235606, "author": "kingkool68", "author_id": 2744, "author_profile": "https://wordpress.stackexchange.com/users/2744", "pm_score": 2, "selected": false, "text": "<p><a href=\"https://developer.wordpress.org/reference/functions/wp_nav_menu/#source\" rel=\"nofollow\">wp_nav_...
2016/08/11
[ "https://wordpress.stackexchange.com/questions/235605", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100817/" ]
After each menu item, I want to add the page excerpt underneath it. So if i have a menu that looks like this: * Home * About * Contact I want to get the page excerpt into the menu like this: * Home + This is the home page excerpt * About + This is the about page excerpt * Contact + This is the contact page excer...
[wp\_nav\_menu()](https://developer.wordpress.org/reference/functions/wp_nav_menu/#source) calls [walk\_nav\_menu\_tree()](https://developer.wordpress.org/reference/functions/walk_nav_menu_tree/#source) which calls the [Walker\_Nav\_Menu class](https://developer.wordpress.org/reference/classes/walker_nav_menu/#source)....
235,617
<p>I'm looking into setting up a development -> staging -> production workflow, and the biggest issue so far is figuring out how to sync the databases.</p> <p>To this end, I'm trying to figure out exactly which actions will affect the filesystem, the database, or both. Here's how I think it works. Please correct me wh...
[ { "answer_id": 235606, "author": "kingkool68", "author_id": 2744, "author_profile": "https://wordpress.stackexchange.com/users/2744", "pm_score": 2, "selected": false, "text": "<p><a href=\"https://developer.wordpress.org/reference/functions/wp_nav_menu/#source\" rel=\"nofollow\">wp_nav_...
2016/08/11
[ "https://wordpress.stackexchange.com/questions/235617", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100820/" ]
I'm looking into setting up a development -> staging -> production workflow, and the biggest issue so far is figuring out how to sync the databases. To this end, I'm trying to figure out exactly which actions will affect the filesystem, the database, or both. Here's how I think it works. Please correct me where I'm wr...
[wp\_nav\_menu()](https://developer.wordpress.org/reference/functions/wp_nav_menu/#source) calls [walk\_nav\_menu\_tree()](https://developer.wordpress.org/reference/functions/walk_nav_menu_tree/#source) which calls the [Walker\_Nav\_Menu class](https://developer.wordpress.org/reference/classes/walker_nav_menu/#source)....
235,652
<p>What would cause a basic <code>get_posts()</code> query to return an empty array during an Ajax function?</p> <p>I have a front end page which loads a form. There is a dropdown which is populated when the page loads with some post titles. The same function that populates the select list values is called via Ajax wh...
[ { "answer_id": 235654, "author": "Krzysztof Grabania", "author_id": 81795, "author_profile": "https://wordpress.stackexchange.com/users/81795", "pm_score": 1, "selected": false, "text": "<p>To get data from AJAX call you have to <code>echo</code> or <code>print</code> it. In WordPress yo...
2016/08/11
[ "https://wordpress.stackexchange.com/questions/235652", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69112/" ]
What would cause a basic `get_posts()` query to return an empty array during an Ajax function? I have a front end page which loads a form. There is a dropdown which is populated when the page loads with some post titles. The same function that populates the select list values is called via Ajax when the value of anoth...
To get data from AJAX call you have to `echo` or `print` it. In WordPress you should use [`wp_send_json()`](https://codex.wordpress.org/Function_Reference/wp_send_json) function to send data as response to call. ``` function mh_get_addons( $args = array() ) { $defaults = array( 'posts_per_page' => -1, ...
235,671
<p>I've been asked to make some changes to a Wordpress site and the previous dev has displayed information from certain current pages on the homepage. </p> <p>What's confusing me is how they've managed to do this... he/she seems to have categorised certain pages by number. For example, the following WP_Query() code se...
[ { "answer_id": 235673, "author": "John O'Sullivan", "author_id": 100858, "author_profile": "https://wordpress.stackexchange.com/users/100858", "pm_score": 1, "selected": false, "text": "<p>I worked it out, when in the admin area of a page/post you can find the post ID in the browser URL:...
2016/08/11
[ "https://wordpress.stackexchange.com/questions/235671", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100858/" ]
I've been asked to make some changes to a Wordpress site and the previous dev has displayed information from certain current pages on the homepage. What's confusing me is how they've managed to do this... he/she seems to have categorised certain pages by number. For example, the following WP\_Query() code seems to ta...
I worked it out, when in the admin area of a page/post you can find the post ID in the browser URL: ``` http://localhost/newsite/wp-admin/post.php?post=1807&action=edit ``` So the previous dev simply uses this page as a 'parent', and refers to it as they set `$id = get_post(1807);` Now the query find posts/pages th...
235,683
<p>I have a loop that pulls the first three posts of a category. I want to use the featured image of the first post pulled for the background of the section the titles and links to these posts are displayed.</p> <p>Is it possible to pull the first image without pulling all other images of posts that were pulled in the...
[ { "answer_id": 235688, "author": "bynicolas", "author_id": 99217, "author_profile": "https://wordpress.stackexchange.com/users/99217", "pm_score": 2, "selected": true, "text": "<p>I believe you are referring to <a href=\"https://wordpress.stackexchange.com/a/235365/99217\">this answer</a...
2016/08/11
[ "https://wordpress.stackexchange.com/questions/235683", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100669/" ]
I have a loop that pulls the first three posts of a category. I want to use the featured image of the first post pulled for the background of the section the titles and links to these posts are displayed. Is it possible to pull the first image without pulling all other images of posts that were pulled in the loop? He...
I believe you are referring to [this answer](https://wordpress.stackexchange.com/a/235365/99217) You could check the index of the current loop and use `get_the_post_thumbnail` to get the image tag or `the_post_thumbnail` to echo it. You can use the `$current_post` [property](https://codex.wordpress.org/Class_Referenc...
235,685
<p>I want to pull the three most recent posts from a specific category. I have the code to do that, but I'm trying to figure out if there's a way to reverse the order of these three posts when displaying/pulling the data?</p> <p>Current Code: <pre><code> 'category_name' =&gt; 'dvd-report', 'posts_per_page' =&g...
[ { "answer_id": 235693, "author": "bynicolas", "author_id": 99217, "author_profile": "https://wordpress.stackexchange.com/users/99217", "pm_score": 3, "selected": true, "text": "<p>Assuming you are refering to the code of <a href=\"https://wordpress.stackexchange.com/a/235365/99217\">this...
2016/08/11
[ "https://wordpress.stackexchange.com/questions/235685", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100669/" ]
I want to pull the three most recent posts from a specific category. I have the code to do that, but I'm trying to figure out if there's a way to reverse the order of these three posts when displaying/pulling the data? Current Code: ``` 'category_name' => 'dvd-report', 'posts_per_page' => 3, ) ); if ($cinemasig...
Assuming you are refering to the code of [this answer](https://wordpress.stackexchange.com/a/235365/99217) Taking the query from that answer ``` $args = array( 'category_name' => 'your-category-slug', 'posts_per_page' => 3, ); $wpse_235685_query = new WP_Query( $args ); ``` you would then, to reverse the or...
235,711
<p>I am having troubles with the archives for a custom post type.</p> <ul> <li>I have a WordPress page at <code>/address/</code></li> <li>I have created dynamic custom posts that are to appear at <code>/address/post#/</code></li> </ul> <p>When I activate this functionality, the WordPress page at <code>/address/</code...
[ { "answer_id": 235713, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 3, "selected": false, "text": "<p>When you register your post type, set the <code>has_archive</code> argument to false. If you chan...
2016/08/11
[ "https://wordpress.stackexchange.com/questions/235711", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100880/" ]
I am having troubles with the archives for a custom post type. * I have a WordPress page at `/address/` * I have created dynamic custom posts that are to appear at `/address/post#/` When I activate this functionality, the WordPress page at `/address/` is replaced with the custom posts archive. How can I stop this fr...
When you register your post type, set the `has_archive` argument to false. If you change it, don't forget to flush your rewrite rules to see the change. Now this works fine if, as you asked, you want to show the page and not the archive. What about the situation where you'd like to show the page's content and also th...
235,729
<p>I have been working for 7 days straight to perfect code that generates a submenu on pages that have children. Since it was so complex I figured I'd write it in my index.php file and then migrate it to a widget plugin once I got it working. It now works flawlessly but when I move it over to my plugin it doesn't ident...
[ { "answer_id": 235713, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 3, "selected": false, "text": "<p>When you register your post type, set the <code>has_archive</code> argument to false. If you chan...
2016/08/12
[ "https://wordpress.stackexchange.com/questions/235729", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62370/" ]
I have been working for 7 days straight to perfect code that generates a submenu on pages that have children. Since it was so complex I figured I'd write it in my index.php file and then migrate it to a widget plugin once I got it working. It now works flawlessly but when I move it over to my plugin it doesn't identify...
When you register your post type, set the `has_archive` argument to false. If you change it, don't forget to flush your rewrite rules to see the change. Now this works fine if, as you asked, you want to show the page and not the archive. What about the situation where you'd like to show the page's content and also th...
235,744
<p>I have a WP theme with its own custom fields. I installed the PowerPress Plugin. The PowerPress Plugin has a textfield called 'Episode Titles'.</p> <p>What I want is when the post is published (or save), WP will grab the data from the custom field 'Speaker' and then populated it into 'Episode Titles'.</p> <p>Can...
[ { "answer_id": 235758, "author": "bagpipper", "author_id": 80397, "author_profile": "https://wordpress.stackexchange.com/users/80397", "pm_score": 2, "selected": false, "text": "<pre><code>/* Do something with the data entered */\nadd_action( 'save_post', 'myplugin_save_postdata' );\n\n/...
2016/08/12
[ "https://wordpress.stackexchange.com/questions/235744", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65697/" ]
I have a WP theme with its own custom fields. I installed the PowerPress Plugin. The PowerPress Plugin has a textfield called 'Episode Titles'. What I want is when the post is published (or save), WP will grab the data from the custom field 'Speaker' and then populated it into 'Episode Titles'. Can someone show me ho...
``` /* Do something with the data entered */ add_action( 'save_post', 'myplugin_save_postdata' ); /* When the post is saved, saves our custom data */ function myplugin_save_postdata( $post_id ) { // First we need to check if the current user is authorised to do this action. if ( 'page' == $_POST['post_type'] ) {...
235,754
<p>Change author, disable comments, enable trackbacks for all items in library with 1 click not each one of them separately?</p>
[ { "answer_id": 235758, "author": "bagpipper", "author_id": 80397, "author_profile": "https://wordpress.stackexchange.com/users/80397", "pm_score": 2, "selected": false, "text": "<pre><code>/* Do something with the data entered */\nadd_action( 'save_post', 'myplugin_save_postdata' );\n\n/...
2016/08/12
[ "https://wordpress.stackexchange.com/questions/235754", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100913/" ]
Change author, disable comments, enable trackbacks for all items in library with 1 click not each one of them separately?
``` /* Do something with the data entered */ add_action( 'save_post', 'myplugin_save_postdata' ); /* When the post is saved, saves our custom data */ function myplugin_save_postdata( $post_id ) { // First we need to check if the current user is authorised to do this action. if ( 'page' == $_POST['post_type'] ) {...
235,789
<p>I have a question that I haven’t been able to find a great answer to. Hoping you guys can help me out. </p> <p>I am in the process of rebuilding our company website. I have a WP theme picked out that I really love (Create from ThemeTrust). I want to use that as the theme for our entire site, except the ecommerce pa...
[ { "answer_id": 235758, "author": "bagpipper", "author_id": 80397, "author_profile": "https://wordpress.stackexchange.com/users/80397", "pm_score": 2, "selected": false, "text": "<pre><code>/* Do something with the data entered */\nadd_action( 'save_post', 'myplugin_save_postdata' );\n\n/...
2016/08/12
[ "https://wordpress.stackexchange.com/questions/235789", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100933/" ]
I have a question that I haven’t been able to find a great answer to. Hoping you guys can help me out. I am in the process of rebuilding our company website. I have a WP theme picked out that I really love (Create from ThemeTrust). I want to use that as the theme for our entire site, except the ecommerce pages. I am ...
``` /* Do something with the data entered */ add_action( 'save_post', 'myplugin_save_postdata' ); /* When the post is saved, saves our custom data */ function myplugin_save_postdata( $post_id ) { // First we need to check if the current user is authorised to do this action. if ( 'page' == $_POST['post_type'] ) {...
235,799
<p>I am trying to implement a solution provided at wcvendors.com knowledgebase and unable to get the indicated results. Can somebody help me with the implementation as to where this is going wrong. I am a beginner at wordpress and php.</p> <p>Basically, I am trying to list vendors by their store location. For this i a...
[ { "answer_id": 235758, "author": "bagpipper", "author_id": 80397, "author_profile": "https://wordpress.stackexchange.com/users/80397", "pm_score": 2, "selected": false, "text": "<pre><code>/* Do something with the data entered */\nadd_action( 'save_post', 'myplugin_save_postdata' );\n\n/...
2016/08/12
[ "https://wordpress.stackexchange.com/questions/235799", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100936/" ]
I am trying to implement a solution provided at wcvendors.com knowledgebase and unable to get the indicated results. Can somebody help me with the implementation as to where this is going wrong. I am a beginner at wordpress and php. Basically, I am trying to list vendors by their store location. For this i am using wc...
``` /* Do something with the data entered */ add_action( 'save_post', 'myplugin_save_postdata' ); /* When the post is saved, saves our custom data */ function myplugin_save_postdata( $post_id ) { // First we need to check if the current user is authorised to do this action. if ( 'page' == $_POST['post_type'] ) {...
235,811
<p>i want to display custom taxonomy images on index.php and for this reason i installed <a href="https://wordpress.org/plugins/taxonomy-images/" rel="nofollow">this plugin</a>. I uploaded my taxonomy images but i couldn't display images on index. I tried the codes which are given by the plugin author. </p> <pre><code...
[ { "answer_id": 235813, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 0, "selected": false, "text": "<p>Are you looking at a taxonomy archive page? You mention you want to display it on index.php, but...
2016/08/12
[ "https://wordpress.stackexchange.com/questions/235811", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100868/" ]
i want to display custom taxonomy images on index.php and for this reason i installed [this plugin](https://wordpress.org/plugins/taxonomy-images/). I uploaded my taxonomy images but i couldn't display images on index. I tried the codes which are given by the plugin author. ``` <?php print apply_filters( 'taxonom...
Just like we use `get_terms()` to get all the terms in a custom taxonomy we can get all the taxonomy images with the below code. Place this code outside the loop to list all the taxonomy images. ``` $terms = apply_filters( 'taxonomy-images-get-terms', '', array( 'taxonomy' => 'ff-portfolio-tag', ) ); if ( ! em...
235,822
<p>I have a sidebar nav menu set up to display the top level pages. I'd like to display subpages (3rd level) when a user clicks on a parent item. For example, when then user clicks 'Detective Division' the two subpages (Violent Crimes and Property Crimes) will show.</p> <p><a href="https://i.stack.imgur.com/TnfWh.png"...
[ { "answer_id": 235828, "author": "Tim Malone", "author_id": 46066, "author_profile": "https://wordpress.stackexchange.com/users/46066", "pm_score": 2, "selected": true, "text": "<p>No need for a custom walker - it's controlled with the <code>depth</code> parameter. At the moment, you're ...
2016/08/12
[ "https://wordpress.stackexchange.com/questions/235822", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100947/" ]
I have a sidebar nav menu set up to display the top level pages. I'd like to display subpages (3rd level) when a user clicks on a parent item. For example, when then user clicks 'Detective Division' the two subpages (Violent Crimes and Property Crimes) will show. [![Here is my menu setup in admin:](https://i.stack.img...
No need for a custom walker - it's controlled with the `depth` parameter. At the moment, you're only showing 2 levels of menus - but you need to set this to `3`! This, however, will only control what is being output. As for the user clicking, hovering or otherwise to actually see the menu, you'll need to apply your ow...
235,880
<p>I'm trying to find a way to change the href of a nav menu page link from the parent theme's default, which goes to its relative page, to another url. For example, I have a menu link "Our Philosophy" that links to the "Our Philosophy" page, but desire for it to go to timecube.com (rip).</p> <p>It seems perhaps using...
[ { "answer_id": 235886, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": false, "text": "<p>You are on right track, with few minor kinks.</p>\n\n<ol>\n<li>You need to modify <code>$atts</code> and return it....
2016/08/13
[ "https://wordpress.stackexchange.com/questions/235880", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100980/" ]
I'm trying to find a way to change the href of a nav menu page link from the parent theme's default, which goes to its relative page, to another url. For example, I have a menu link "Our Philosophy" that links to the "Our Philosophy" page, but desire for it to go to timecube.com (rip). It seems perhaps using a filter ...
You are on right track, with few minor kinks. 1. You need to modify `$atts` and return it. Any arguments after the first one are provided for information and should not be changed. 2. You need to tell `add_filter()` that you expect more than one argument. The example with some debug code would be along the lines of: ...
235,893
<p>I'm trying to display user <a href="http://en.gravatar.com/" rel="nofollow">gravatars</a> on this page <a href="http://gepc.themelot.com/survey-comparison/433747624/293281083/" rel="nofollow">http://gepc.themelot.com/survey-comparison/433747624/293281083/</a> but the page keeps showing the default '<a href="http://e...
[ { "answer_id": 235886, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": false, "text": "<p>You are on right track, with few minor kinks.</p>\n\n<ol>\n<li>You need to modify <code>$atts</code> and return it....
2016/08/14
[ "https://wordpress.stackexchange.com/questions/235893", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10241/" ]
I'm trying to display user [gravatars](http://en.gravatar.com/) on this page <http://gepc.themelot.com/survey-comparison/433747624/293281083/> but the page keeps showing the default '[mystery man](http://en.gravatar.com/site/implement/images/#default-image)' avatar. I inspected the page element and it returns the same ...
You are on right track, with few minor kinks. 1. You need to modify `$atts` and return it. Any arguments after the first one are provided for information and should not be changed. 2. You need to tell `add_filter()` that you expect more than one argument. The example with some debug code would be along the lines of: ...
235,905
<p>I'm working on creating a shortcode which is meant to change the css and js dynamically for that shortcode based on the situation. Now the problem is that I not getting a clue about how to use <code>add_action()</code> inside a <code>add_shortcode()</code>. Let me give you an example snippet code so that you guys ca...
[ { "answer_id": 235886, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": false, "text": "<p>You are on right track, with few minor kinks.</p>\n\n<ol>\n<li>You need to modify <code>$atts</code> and return it....
2016/08/14
[ "https://wordpress.stackexchange.com/questions/235905", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50584/" ]
I'm working on creating a shortcode which is meant to change the css and js dynamically for that shortcode based on the situation. Now the problem is that I not getting a clue about how to use `add_action()` inside a `add_shortcode()`. Let me give you an example snippet code so that you guys can better understand me: ...
You are on right track, with few minor kinks. 1. You need to modify `$atts` and return it. Any arguments after the first one are provided for information and should not be changed. 2. You need to tell `add_filter()` that you expect more than one argument. The example with some debug code would be along the lines of: ...
235,957
<p>I've created a shortcode for a sitemap page. When I make a change on the page and click update I get a headers already sent error. Below is my shortcode and the two error messages. I'm wondering if I need to work <code>ob_start()</code> and <code>ob_get_clean()</code> into my function but I'm not 100% positive how i...
[ { "answer_id": 235958, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 2, "selected": false, "text": "<p>You need to return the value from <a href=\"https://developer.wordpress.org/reference/functions/wp_list_pages/...
2016/08/15
[ "https://wordpress.stackexchange.com/questions/235957", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64789/" ]
I've created a shortcode for a sitemap page. When I make a change on the page and click update I get a headers already sent error. Below is my shortcode and the two error messages. I'm wondering if I need to work `ob_start()` and `ob_get_clean()` into my function but I'm not 100% positive how it should be formatted. `...
The adjustment to my function below fixed the issue but I wanted to make sure that this is the right way to handle the shortcode. I've added ob\_start(); and ob\_get\_clean(); to the function. Is this the correct way to handle something like this? ``` function site_map2( $atts ) { $atts = shortcode_atts( a...
235,993
<p>In my plugin settings page, I have a list of checkboxes that store the value into an array. While the it works as expected, whenever I uncheck all of the checkboxes and save those changes I get the following error:</p> <blockquote> <p><strong>Notice: Undefined index:</strong> <em>remove_field</em> in ...\settings...
[ { "answer_id": 236001, "author": "jdm2112", "author_id": 45202, "author_profile": "https://wordpress.stackexchange.com/users/45202", "pm_score": 3, "selected": true, "text": "<p>I'm not seeing the original snippet from before so I'm not sure of the context anymore. The undefined index n...
2016/08/15
[ "https://wordpress.stackexchange.com/questions/235993", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98212/" ]
In my plugin settings page, I have a list of checkboxes that store the value into an array. While the it works as expected, whenever I uncheck all of the checkboxes and save those changes I get the following error: > > **Notice: Undefined index:** *remove\_field* in ...\settings-profile.php on line 19 > > > Below...
I'm not seeing the original snippet from before so I'm not sure of the context anymore. The undefined index notice you are getting is telling you that `$_POST['remove_fiel‌​d']` does not exist. If no checkbox in your array was set, the `$_POST` array will not have an index for `'remove_field'`, and you'll see the error...
236,003
<p>When uploading a site logo, I get a 403 Forbidden HTTP error.</p> <p>Also, the Inspect Element preview shows this page:</p> <p><a href="https://i.stack.imgur.com/JiO23.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JiO23.jpg" alt="enter image description here"></a></p> <p>On the site itself, i...
[ { "answer_id": 236001, "author": "jdm2112", "author_id": 45202, "author_profile": "https://wordpress.stackexchange.com/users/45202", "pm_score": 3, "selected": true, "text": "<p>I'm not seeing the original snippet from before so I'm not sure of the context anymore. The undefined index n...
2016/08/15
[ "https://wordpress.stackexchange.com/questions/236003", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101064/" ]
When uploading a site logo, I get a 403 Forbidden HTTP error. Also, the Inspect Element preview shows this page: [![enter image description here](https://i.stack.imgur.com/JiO23.jpg)](https://i.stack.imgur.com/JiO23.jpg) On the site itself, it just says "http error". I tried disabling nonces, no change. I had done `...
I'm not seeing the original snippet from before so I'm not sure of the context anymore. The undefined index notice you are getting is telling you that `$_POST['remove_fiel‌​d']` does not exist. If no checkbox in your array was set, the `$_POST` array will not have an index for `'remove_field'`, and you'll see the error...
236,026
<p>I just create a simple WordPress theme, everything looks fine but when I use a plugins which need shortcode.</p> <p>I put the short code in a page (like this [user-submitted-pos‌​ts]), on front end, it show same short code. When I change to another theme, the short code works fine.</p> <p>Shortcode doesn't work, i...
[ { "answer_id": 236029, "author": "anmari", "author_id": 3569, "author_profile": "https://wordpress.stackexchange.com/users/3569", "pm_score": 1, "selected": false, "text": "<p>Suggest you look at one of the twenty-x themes to see what's different and read up on using \"apply_filters('the...
2016/08/16
[ "https://wordpress.stackexchange.com/questions/236026", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31425/" ]
I just create a simple WordPress theme, everything looks fine but when I use a plugins which need shortcode. I put the short code in a page (like this [user-submitted-pos‌​ts]), on front end, it show same short code. When I change to another theme, the short code works fine. Shortcode doesn't work, is this need funct...
You should add to theme something like this: ``` add_filter('shortcode_function_name', 'do_shortcode'); ``` This should be enough. Here you can find the documentation related to the shortcodes: <https://developer.wordpress.org/reference/functions/do_shortcode/>
236,063
<p>I am adding the variable product in woocommerce pragmatically but the product created in the admin panel is always a simple product. I am using the following code to set the product type variable.</p> <pre><code>$producttype = wp_set_object_terms($post_id, 'variable', 'product_type'); </code></pre> <p>When I print...
[ { "answer_id": 237174, "author": "SuperNERD", "author_id": 101671, "author_profile": "https://wordpress.stackexchange.com/users/101671", "pm_score": 1, "selected": false, "text": "<p>Not sure exactly where you're adding that code, but there is a generally accepted way of doing this, whi...
2016/08/16
[ "https://wordpress.stackexchange.com/questions/236063", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83446/" ]
I am adding the variable product in woocommerce pragmatically but the product created in the admin panel is always a simple product. I am using the following code to set the product type variable. ``` $producttype = wp_set_object_terms($post_id, 'variable', 'product_type'); ``` When I print the output in `$productty...
Not sure exactly where you're adding that code, but there is a generally accepted way of doing this, which is outlined pretty well here: [How to add a new product type on woocommerce product types?](https://wordpress.stackexchange.com/questions/120215/how-to-add-a-new-product-type-on-woocommerce-product-types/120220) ...
236,069
<p>Recently I uploaded a WordPress site, but the page url still displays the old test site url, and the place where my new url is displaying doesnt get the page.</p>
[ { "answer_id": 237174, "author": "SuperNERD", "author_id": 101671, "author_profile": "https://wordpress.stackexchange.com/users/101671", "pm_score": 1, "selected": false, "text": "<p>Not sure exactly where you're adding that code, but there is a generally accepted way of doing this, whi...
2016/08/16
[ "https://wordpress.stackexchange.com/questions/236069", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101095/" ]
Recently I uploaded a WordPress site, but the page url still displays the old test site url, and the place where my new url is displaying doesnt get the page.
Not sure exactly where you're adding that code, but there is a generally accepted way of doing this, which is outlined pretty well here: [How to add a new product type on woocommerce product types?](https://wordpress.stackexchange.com/questions/120215/how-to-add-a-new-product-type-on-woocommerce-product-types/120220) ...
236,071
<p>I want to use a one taxonomy of two CPT. But I want to have different URL.</p> <p>Like this:</p> <p><strong>city</strong> - taxonomy (taxonomy data is used in two CPT)</p> <p><strong>people</strong> - CPT</p> <p><strong>car</strong> - CPT</p> <p>I want:</p> <p>site.com/people/born/LA</p> <p>site.com/car/place...
[ { "answer_id": 237174, "author": "SuperNERD", "author_id": 101671, "author_profile": "https://wordpress.stackexchange.com/users/101671", "pm_score": 1, "selected": false, "text": "<p>Not sure exactly where you're adding that code, but there is a generally accepted way of doing this, whi...
2016/08/16
[ "https://wordpress.stackexchange.com/questions/236071", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60574/" ]
I want to use a one taxonomy of two CPT. But I want to have different URL. Like this: **city** - taxonomy (taxonomy data is used in two CPT) **people** - CPT **car** - CPT I want: site.com/people/born/LA site.com/car/place/LA Thus in the first case I show people born in the LA, and in the second case, cars bein...
Not sure exactly where you're adding that code, but there is a generally accepted way of doing this, which is outlined pretty well here: [How to add a new product type on woocommerce product types?](https://wordpress.stackexchange.com/questions/120215/how-to-add-a-new-product-type-on-woocommerce-product-types/120220) ...
236,081
<p>I've been messing around with rewrites and <code>query_var</code> to generate some listings, for example:</p> <ul> <li>~/my-page/?my_var=1</li> <li>~/my-page/?my_var=2</li> <li>~/my-page/?my_var=3</li> </ul> <p>After perusing StackExchange and the interwebs a bit, it seems that the overwhelming consensus is that <...
[ { "answer_id": 237174, "author": "SuperNERD", "author_id": 101671, "author_profile": "https://wordpress.stackexchange.com/users/101671", "pm_score": 1, "selected": false, "text": "<p>Not sure exactly where you're adding that code, but there is a generally accepted way of doing this, whi...
2016/08/16
[ "https://wordpress.stackexchange.com/questions/236081", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47880/" ]
I've been messing around with rewrites and `query_var` to generate some listings, for example: * ~/my-page/?my\_var=1 * ~/my-page/?my\_var=2 * ~/my-page/?my\_var=3 After perusing StackExchange and the interwebs a bit, it seems that the overwhelming consensus is that [add\_rewrite\_endpoint](https://codex.wordpress.or...
Not sure exactly where you're adding that code, but there is a generally accepted way of doing this, which is outlined pretty well here: [How to add a new product type on woocommerce product types?](https://wordpress.stackexchange.com/questions/120215/how-to-add-a-new-product-type-on-woocommerce-product-types/120220) ...
236,122
<p>I would like to turn off the emails that the admin gets when a new user registers. We are getting a lot of emails because of new registrations (they are legitimate registrations) but I just don't want to see the email telling me that someone has signed up again and again.</p> <p>So far I've tried <a href="http://...
[ { "answer_id": 236132, "author": "Jarod Thornton", "author_id": 44017, "author_profile": "https://wordpress.stackexchange.com/users/44017", "pm_score": 2, "selected": false, "text": "<p><strong>After some research I determined that you can disable all notification emails, but not those t...
2016/08/16
[ "https://wordpress.stackexchange.com/questions/236122", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77767/" ]
I would like to turn off the emails that the admin gets when a new user registers. We are getting a lot of emails because of new registrations (they are legitimate registrations) but I just don't want to see the email telling me that someone has signed up again and again. So far I've tried [installing plugins](http://...
**Generic Pluggable Approach for WordPress < 4.6 (See [@birgire's Answer](https://wordpress.stackexchange.com/a/236301/25324) for > 4.6)** Pluggable functions are one of the more depressing relics of WordPress's past and come with a slew of intricacies. That directly modifying the core file (which is entirely inadvisa...
236,134
<p>I have custom post type for "rooms" registered, along with a custom taxonomy. Here is the code:</p> <pre><code>&lt;?php /*******************************************/ /* Rooms CPT /*******************************************/ add_action('init', 'room_register'); function room_register() { $labels = array( ...
[ { "answer_id": 236132, "author": "Jarod Thornton", "author_id": 44017, "author_profile": "https://wordpress.stackexchange.com/users/44017", "pm_score": 2, "selected": false, "text": "<p><strong>After some research I determined that you can disable all notification emails, but not those t...
2016/08/16
[ "https://wordpress.stackexchange.com/questions/236134", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/91661/" ]
I have custom post type for "rooms" registered, along with a custom taxonomy. Here is the code: ``` <?php /*******************************************/ /* Rooms CPT /*******************************************/ add_action('init', 'room_register'); function room_register() { $labels = array( 'name' => _...
**Generic Pluggable Approach for WordPress < 4.6 (See [@birgire's Answer](https://wordpress.stackexchange.com/a/236301/25324) for > 4.6)** Pluggable functions are one of the more depressing relics of WordPress's past and come with a slew of intricacies. That directly modifying the core file (which is entirely inadvisa...
236,137
<p>I am setting up a WordPress site locally from a site online. I downloaded the files and database. I used InstantWP to set up the site. I imported the database and moved over the proper files for the local site. When I go to the site, I get these errors:</p> <blockquote> <p>Warning: call_user_func_array() expects par...
[ { "answer_id": 236132, "author": "Jarod Thornton", "author_id": 44017, "author_profile": "https://wordpress.stackexchange.com/users/44017", "pm_score": 2, "selected": false, "text": "<p><strong>After some research I determined that you can disable all notification emails, but not those t...
2016/08/16
[ "https://wordpress.stackexchange.com/questions/236137", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101124/" ]
I am setting up a WordPress site locally from a site online. I downloaded the files and database. I used InstantWP to set up the site. I imported the database and moved over the proper files for the local site. When I go to the site, I get these errors: > > Warning: call\_user\_func\_array() expects parameter 1 to be...
**Generic Pluggable Approach for WordPress < 4.6 (See [@birgire's Answer](https://wordpress.stackexchange.com/a/236301/25324) for > 4.6)** Pluggable functions are one of the more depressing relics of WordPress's past and come with a slew of intricacies. That directly modifying the core file (which is entirely inadvisa...
236,193
<p>The <code>wp_mail</code> function doesn't work after updating WordPress to version <a href="https://make.wordpress.org/core/4-6/" rel="nofollow">4.6</a>.</p> <p>My code is:</p> <pre><code>$headers = 'From: ' . $this-&gt;from_name . ' &lt;' . $this-&gt;from_email .'&gt;' . "\r\n"; wp_mail( $service-&gt;getEmail(), ...
[ { "answer_id": 236206, "author": "TheGentleman", "author_id": 68563, "author_profile": "https://wordpress.stackexchange.com/users/68563", "pm_score": 2, "selected": false, "text": "<p>On you on WAMP? Regardless, it sounds like the built-in php <a href=\"http://php.net/manual/en/function...
2016/08/17
[ "https://wordpress.stackexchange.com/questions/236193", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100743/" ]
The `wp_mail` function doesn't work after updating WordPress to version [4.6](https://make.wordpress.org/core/4-6/). My code is: ``` $headers = 'From: ' . $this->from_name . ' <' . $this->from_email .'>' . "\r\n"; wp_mail( $service->getEmail(), $this->admin_daily_subject, $admin_daily_message, $headers ); ``` It wo...
The solution has been found here - [Make WordPress Core](https://core.trac.wordpress.org/attachment/ticket/37736/37736.patch) I've made changes in wp-includes/pluggable.php on line 352 from ``` $phpmailer->setFrom( $from_email, $from_name ); ``` to ``` $phpmailer->setFrom( $from_email, $from_name, false ); ``` ...
236,213
<pre><code>&lt;?php $args = array( 'post_type' =&gt; 'product', 'stock' =&gt; 1, 'posts_per_page' =&gt; 4, 'product_cat' =&gt; '&lt;?php echo get_theme_mod('vatname', 'Clothing'); ?&gt;', 'orderby' =&gt;'date', 'order' =&gt; 'ASC' ); $loop = new WP_Query( $args ); while ( $loop-&gt;have_posts(...
[ { "answer_id": 236206, "author": "TheGentleman", "author_id": 68563, "author_profile": "https://wordpress.stackexchange.com/users/68563", "pm_score": 2, "selected": false, "text": "<p>On you on WAMP? Regardless, it sounds like the built-in php <a href=\"http://php.net/manual/en/function...
2016/08/17
[ "https://wordpress.stackexchange.com/questions/236213", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101171/" ]
``` <?php $args = array( 'post_type' => 'product', 'stock' => 1, 'posts_per_page' => 4, 'product_cat' => '<?php echo get_theme_mod('vatname', 'Clothing'); ?>', 'orderby' =>'date', 'order' => 'ASC' ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); global $prod...
The solution has been found here - [Make WordPress Core](https://core.trac.wordpress.org/attachment/ticket/37736/37736.patch) I've made changes in wp-includes/pluggable.php on line 352 from ``` $phpmailer->setFrom( $from_email, $from_name ); ``` to ``` $phpmailer->setFrom( $from_email, $from_name, false ); ``` ...
236,234
<p>How to display image in email header. I tried below, it in gmail it is not displaying the image. Please any one help me to resolve this. Thanks in advance.</p> <pre><code> $to = $_REQUEST['userEmail']; $firstName = $_REQUEST['firstName']; $lastName = $_REQUEST['lastName']; $email = $_REQUEST['email']...
[ { "answer_id": 236240, "author": "Joseph Seyi Taiwo", "author_id": 101144, "author_profile": "https://wordpress.stackexchange.com/users/101144", "pm_score": 0, "selected": false, "text": "<p>You can add your <code>$headers</code> before the form.\nAlso parse <code>$headers</code> like th...
2016/08/17
[ "https://wordpress.stackexchange.com/questions/236234", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98499/" ]
How to display image in email header. I tried below, it in gmail it is not displaying the image. Please any one help me to resolve this. Thanks in advance. ``` $to = $_REQUEST['userEmail']; $firstName = $_REQUEST['firstName']; $lastName = $_REQUEST['lastName']; $email = $_REQUEST['email']; $questio...
The email header is not the same as the `<head>` of an HTML document (even if that document is an email). So the question shouldn't be how to display an image in the email header because the answer is that you can't. Second, the same thing holds true for an HTML document. The `<head>` section (where the `<img>` tag is...
236,235
<p>How do we get wp_link_pages() to show the Next and Previous button when it is the start of the multi-page post as well at the end of a multipage. Currently it only shows Next if it is the first page, and Previous at the end of the page. </p>
[ { "answer_id": 236246, "author": "Joseph Seyi Taiwo", "author_id": 101144, "author_profile": "https://wordpress.stackexchange.com/users/101144", "pm_score": -1, "selected": false, "text": "<p>You can take a look at this\n<a href=\"https://codex.wordpress.org/Function_Reference/wp_link_pa...
2016/08/17
[ "https://wordpress.stackexchange.com/questions/236235", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101181/" ]
How do we get wp\_link\_pages() to show the Next and Previous button when it is the start of the multi-page post as well at the end of a multipage. Currently it only shows Next if it is the first page, and Previous at the end of the page.
I've just faced the same issue and here is my solution. I'm using globals to get current page and total page count: ``` /* first i'm looking into $multipage global to check if the post actually has pages */ global $multipage; if ( $multipage === 1 ) { global $page; // this is current page number global $nump...
236,249
<p>I'm trying to use a custom endpoint (basically to get a random sorting working) and am using the following code:</p> <pre><code>// Custom WP API endpoint function theme_enable_random_api() { // create json-api endpoint add_action('rest_api_init', function () { // http://example.com/wp-json/random...
[ { "answer_id": 236289, "author": "Chris Morris", "author_id": 39242, "author_profile": "https://wordpress.stackexchange.com/users/39242", "pm_score": 4, "selected": true, "text": "<p>You can call the REST API methods to prepare your output in the same way that the plugin does by default,...
2016/08/17
[ "https://wordpress.stackexchange.com/questions/236249", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51164/" ]
I'm trying to use a custom endpoint (basically to get a random sorting working) and am using the following code: ``` // Custom WP API endpoint function theme_enable_random_api() { // create json-api endpoint add_action('rest_api_init', function () { // http://example.com/wp-json/random/v2/posts ...
You can call the REST API methods to prepare your output in the same way that the plugin does by default, this will also allow any plugins to tie into the output as you have used the ACF plugin as seen in your example output. The `WP_REST_Posts_Controller` class has the following in its get posts method ``` $posts_q...
236,256
<p>I have purchased few plugins and they work fine, but one existing plugin doesn't work. The plugin developer telling: refund or provide admin access.</p> <p>How to handle such requests? <strong>Create a special user with some admin rights just be able to work on plugin directory?</strong> </p>
[ { "answer_id": 236289, "author": "Chris Morris", "author_id": 39242, "author_profile": "https://wordpress.stackexchange.com/users/39242", "pm_score": 4, "selected": true, "text": "<p>You can call the REST API methods to prepare your output in the same way that the plugin does by default,...
2016/08/17
[ "https://wordpress.stackexchange.com/questions/236256", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101194/" ]
I have purchased few plugins and they work fine, but one existing plugin doesn't work. The plugin developer telling: refund or provide admin access. How to handle such requests? **Create a special user with some admin rights just be able to work on plugin directory?**
You can call the REST API methods to prepare your output in the same way that the plugin does by default, this will also allow any plugins to tie into the output as you have used the ACF plugin as seen in your example output. The `WP_REST_Posts_Controller` class has the following in its get posts method ``` $posts_q...
236,260
<p>I've used a small javascript file to create an off canvas push navbar. I loaded the file as described in the Wordpres Codex: </p> <pre><code>function sidebar () { wp_enqueue_script('theme-js', get_stylesheet_directory_uri() . '/js/nav-sidebar.js',array( 'jquery' ),$version,true ); } add_action('wp_enqueue_scripts',...
[ { "answer_id": 236273, "author": "Rituparna sonowal", "author_id": 71232, "author_profile": "https://wordpress.stackexchange.com/users/71232", "pm_score": 0, "selected": false, "text": "<p>I am assuming you have already enqueued bootstrap js in your theme functions.php with handle named ...
2016/08/18
[ "https://wordpress.stackexchange.com/questions/236260", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25605/" ]
I've used a small javascript file to create an off canvas push navbar. I loaded the file as described in the Wordpres Codex: ``` function sidebar () { wp_enqueue_script('theme-js', get_stylesheet_directory_uri() . '/js/nav-sidebar.js',array( 'jquery' ),$version,true ); } add_action('wp_enqueue_scripts', 'sidebar'); ...
Expanding [@RRikesh](https://wordpress.stackexchange.com/users/17305/rrikesh) comment, you might have enqueued/loaded the `bootstap.js` with same handle `theme-js`. So only one script gets enqueued. Try to use different handle for example `nav-sidebar`. See the following code. Also it's recommended to use prefix, here...
236,279
<p>How can I make my own custom sidebar for my blog when my theme does not provide an option to add a custom sidebar?</p>
[ { "answer_id": 236286, "author": "user53340", "author_id": 98778, "author_profile": "https://wordpress.stackexchange.com/users/98778", "pm_score": 1, "selected": false, "text": "<p>You need to register the widget area in your themes functions.php file. Your code should look something lik...
2016/08/18
[ "https://wordpress.stackexchange.com/questions/236279", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93995/" ]
How can I make my own custom sidebar for my blog when my theme does not provide an option to add a custom sidebar?
You need to register the widget area in your themes functions.php file. Your code should look something like this. ``` //register the widget area function your_function_name() { register_sidebar(array( 'name' => esc_html__('Sidebar', 'your_theme_name'), 'id' => 'sidebar-1', 'description...
236,298
<p>I have tried <code>preformatted</code> button, <code>Paste as text</code> button or <code>Text</code> tab element before pasting source code, WordPress always stripped indent tabs and broke code formatting.</p> <p>For example, the source code:</p> <pre><code>final class HtmlAttr { /** * Constructor * * ...
[ { "answer_id": 236286, "author": "user53340", "author_id": 98778, "author_profile": "https://wordpress.stackexchange.com/users/98778", "pm_score": 1, "selected": false, "text": "<p>You need to register the widget area in your themes functions.php file. Your code should look something lik...
2016/08/18
[ "https://wordpress.stackexchange.com/questions/236298", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92212/" ]
I have tried `preformatted` button, `Paste as text` button or `Text` tab element before pasting source code, WordPress always stripped indent tabs and broke code formatting. For example, the source code: ``` final class HtmlAttr { /** * Constructor * * @param string $filter A filter hook to modify the a...
You need to register the widget area in your themes functions.php file. Your code should look something like this. ``` //register the widget area function your_function_name() { register_sidebar(array( 'name' => esc_html__('Sidebar', 'your_theme_name'), 'id' => 'sidebar-1', 'description...
236,318
<p>Using the WordPress <code>the_content</code> tag, I am running a custom function to search for all images that do not have a <code>width</code> and <code>height</code> attribute set and insert the proper dimensions. Below is the function:</p> <pre><code>add_filter( 'the_content', 'add_img_dimensions' ); function a...
[ { "answer_id": 236369, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 1, "selected": false, "text": "<p>You always need to return the full content when using <code>the_content</code> filter. But the code you have w...
2016/08/18
[ "https://wordpress.stackexchange.com/questions/236318", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98212/" ]
Using the WordPress `the_content` tag, I am running a custom function to search for all images that do not have a `width` and `height` attribute set and insert the proper dimensions. Below is the function: ``` add_filter( 'the_content', 'add_img_dimensions' ); function add_img_dimensions( $image_no_dimensions ) { // ...
Tested and confirmed that this works: ``` add_filter( 'the_content', 'add_image_dimensions' ); function add_image_dimensions( $content ) { preg_match_all( '/<img[^>]+>/i', $content, $images); if (count($images) < 1) return $content; foreach ($images[0] as $image) { preg_match_all( '/(al...
236,323
<p>I have created a <code>Custom Post Type</code> to publish multiple images together.</p> <p>--->>> title &lt;&lt;&lt;--- <br> --->>> image default - thumbnail &lt;&lt;&lt;--- <br> --->>> cotent &lt;&lt;&lt;--- <br> --->>>images&lt;&lt;&lt;--- <br> --->>>images&lt;&lt;&lt;--- <br> .....</p> <p>The first three sectio...
[ { "answer_id": 236325, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>As you rightly note storing URL is inconvenient for users. Also it is inconvenient for code, since it is hard to pe...
2016/08/18
[ "https://wordpress.stackexchange.com/questions/236323", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94215/" ]
I have created a `Custom Post Type` to publish multiple images together. --->>> title <<<--- --->>> image default - thumbnail <<<--- --->>> cotent <<<--- --->>>images<<<--- --->>>images<<<--- ..... The first three sections (title, image default and content) is the basics. Is ready. I thought abou...
--- UPDATED -------- I got it! I made this way, I created a gallery within the wordpress editor. And with foreach, I took the ID of each image and display in the Loop: ``` <?php global $post; $gallery = get_post_gallery_images( $post ); foreach( $gallery as $image_url ) { ?> <div class="item"> <figure style="mar...
236,332
<p>When the a loop runs can I have each new post it grabs its own HTML class?</p> <h3>For example</h3> <ul> <li>Loop runs</li> <li>First item gets <code>class="first"</code></li> <li>Second item gets <code>class="second"</code></li> <li>and so on...</li> </ul> <p>Or each post just gets an equivalent numbered <code>c...
[ { "answer_id": 236325, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>As you rightly note storing URL is inconvenient for users. Also it is inconvenient for code, since it is hard to pe...
2016/08/18
[ "https://wordpress.stackexchange.com/questions/236332", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82731/" ]
When the a loop runs can I have each new post it grabs its own HTML class? ### For example * Loop runs * First item gets `class="first"` * Second item gets `class="second"` * and so on... Or each post just gets an equivalent numbered `class=` 1, 2, 3, 4, etc. I've just been using CSS with `nth-child()` to target ea...
--- UPDATED -------- I got it! I made this way, I created a gallery within the wordpress editor. And with foreach, I took the ID of each image and display in the Loop: ``` <?php global $post; $gallery = get_post_gallery_images( $post ); foreach( $gallery as $image_url ) { ?> <div class="item"> <figure style="mar...
236,335
<p>I have a client who wants to close down access to the entire site, every post, category page, archive etc (while keeping the content), except for three specific pages (Start, about us, contact).</p> <p>None of the membership plugins seem to address this, only logged in roles? I feel like this is the most simple thi...
[ { "answer_id": 236340, "author": "mukto90", "author_id": 57944, "author_profile": "https://wordpress.stackexchange.com/users/57944", "pm_score": 3, "selected": true, "text": "<p>If you want to show a message, use this code in your <code>functions.php</code> file-</p>\n\n<pre><code>functi...
2016/08/18
[ "https://wordpress.stackexchange.com/questions/236335", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32862/" ]
I have a client who wants to close down access to the entire site, every post, category page, archive etc (while keeping the content), except for three specific pages (Start, about us, contact). None of the membership plugins seem to address this, only logged in roles? I feel like this is the most simple thing ever, b...
If you want to show a message, use this code in your `functions.php` file- ``` function se_236335_hide_content( $content ){ $pages = array( 8, 26, 35 ); // allowed page IDs if( ! in_array( get_the_id(), $pages ) ){ return 'Message here..'; } return $content; } add_filter( 'the_content', 'se_23...
236,370
<p>I'm new to WordPress. I'm including my file using</p> <pre><code>&lt;link rel='stylesheet' href="&lt;?php bloginfo("stylesheet_url")?&gt;"/&gt; </code></pre> <p>But if i enqueue my css file in <code>functions.php</code> it is not working. Why? Where is my mistake?</p> <pre><code>&lt;?php wp_enqueue_style('style',...
[ { "answer_id": 236372, "author": "bynicolas", "author_id": 99217, "author_profile": "https://wordpress.stackexchange.com/users/99217", "pm_score": 2, "selected": false, "text": "<p>You are calling the function wrong. You have not given your filename, just a directory.</p>\n\n<p>From the ...
2016/08/19
[ "https://wordpress.stackexchange.com/questions/236370", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101257/" ]
I'm new to WordPress. I'm including my file using ``` <link rel='stylesheet' href="<?php bloginfo("stylesheet_url")?>"/> ``` But if i enqueue my css file in `functions.php` it is not working. Why? Where is my mistake? ``` <?php wp_enqueue_style('style',get_template_directory_uri())?> ``` What is the solution for ...
You are calling the function wrong. You have not given your filename, just a directory. From the [codex](https://developer.wordpress.org/reference/functions/wp_enqueue_style/) ``` wp_enqueue_style( string $handle, string $src = false, array $deps = array(), string|bool|null $ver = false, string $media = 'all' ) ``` ...
236,400
<p>I made HTML/CSS design of a web site, and now I need to convert it to WordPress. The part that I am working on right now is Adding slick slider to show only on my WP front page. It works perfectly in HTML (because there I incorporated javascript which could be found on actual slick slider website and initiated throu...
[ { "answer_id": 236407, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 2, "selected": true, "text": "<p>First of all you've written <code>array(jquery)</code> instead of <code>array('jquery')</code>. And also ha...
2016/08/19
[ "https://wordpress.stackexchange.com/questions/236400", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101279/" ]
I made HTML/CSS design of a web site, and now I need to convert it to WordPress. The part that I am working on right now is Adding slick slider to show only on my WP front page. It works perfectly in HTML (because there I incorporated javascript which could be found on actual slick slider website and initiated through ...
First of all you've written `array(jquery)` instead of `array('jquery')`. And also has not defined the `slickinit` enqueue position. So the right code will be- ``` //Enqueue scripts add_action('wp_enqueue_scripts', 'wp_enqueue_all_scripts', 999); function wp_enqueue_all_scripts(){ //add slick slider wp_regi...
236,425
<p>I'm using the Gazette theme which has a jet pack enabled featured posts grid when the front page is set to show latest posts.</p> <p>I would like to use a static page instead of recent posts, but keep the featured posts grid. </p> <hr> <p><strong>UPDATE</strong></p> <p>I was able to figure this out with a littl...
[ { "answer_id": 236428, "author": "user53340", "author_id": 98778, "author_profile": "https://wordpress.stackexchange.com/users/98778", "pm_score": 0, "selected": false, "text": "<p>If I understand your question which is to be honest a little vague, you should be able to change if <code>(...
2016/08/19
[ "https://wordpress.stackexchange.com/questions/236425", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44017/" ]
I'm using the Gazette theme which has a jet pack enabled featured posts grid when the front page is set to show latest posts. I would like to use a static page instead of recent posts, but keep the featured posts grid. --- **UPDATE** I was able to figure this out with a little moral support from the community Lin...
Bingo. I added the featured content template (as originally and later suggested by @user53340) to the page.php with a condition so the featured grid would only display on the page I designate. **Add to page.php** ``` if ( is_page(ID) ) { // Include the featured content template. get_template_part( 'featured-c...
236,433
<p>I get the same results with these to lines, so what does <code>apply_filters</code> do?</p> <pre><code>Line 1 : echo $instance['title']; Line 2 : echo apply_filters('widget_title', $instance['title']); </code></pre>
[ { "answer_id": 236435, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 0, "selected": false, "text": "<p>If you haven't written a filter using <a href=\"https://developer.wordpress.org/reference/functions/add_filter/\...
2016/08/19
[ "https://wordpress.stackexchange.com/questions/236433", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101071/" ]
I get the same results with these to lines, so what does `apply_filters` do? ``` Line 1 : echo $instance['title']; Line 2 : echo apply_filters('widget_title', $instance['title']); ```
Well, `apply_filter` creates a global filter hook which can be used dynamically all over the system. Which gives you the ability to filter the content of the `$instance['title']`, means you can over ride the content as well as can modify the content. Here is the example- ``` add_filter( 'widget_title', 'widget_title_t...
236,434
<p>When using <code>comments_template()</code>, all comments starts with <code>{ Username } says</code>. </p> <p>How can I remove that "<em>says</em>" part? In most solutions that I found, it suggests using CSS like:</p> <pre><code>.says { display: none; } </code></pre> <p>But the string isn't wrapped in a <code>div...
[ { "answer_id": 236445, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 2, "selected": false, "text": "<p>Hope this is gonna help. Please try this snippet. Put it in your themes <code>functions.php</code> or you ...
2016/08/19
[ "https://wordpress.stackexchange.com/questions/236434", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54742/" ]
When using `comments_template()`, all comments starts with `{ Username } says`. How can I remove that "*says*" part? In most solutions that I found, it suggests using CSS like: ``` .says { display: none; } ``` But the string isn't wrapped in a `div` called `says`. Any suggestions? Thanks!
Hope this is gonna help. Please try this snippet. Put it in your themes `functions.php` or you could it load it thorough a plugin or any other way- ``` function the_dramatist_remove_says_from_comment( $translation, $text, $domain ) { //what text you want to have instead of 'says' in comments. For removing 'says' k...
236,457
<p>i'm having a trouble with Wordpress, with the function <code>update_user_meta()</code></p> <p>I'm trying to update or add a new custom meta value for the user, who already have the custom meta working on the edit profile. But when i do the function <code>update_user_meta()</code> outside the <code>edit-profile.php<...
[ { "answer_id": 236458, "author": "Aamer Shahzad", "author_id": 42772, "author_profile": "https://wordpress.stackexchange.com/users/42772", "pm_score": 1, "selected": true, "text": "<p><code>wp_get_current_user()</code> returns an object. <code>update_user_meta( $user_id, $meta_key, $meta...
2016/08/19
[ "https://wordpress.stackexchange.com/questions/236457", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101301/" ]
i'm having a trouble with Wordpress, with the function `update_user_meta()` I'm trying to update or add a new custom meta value for the user, who already have the custom meta working on the edit profile. But when i do the function `update_user_meta()` outside the `edit-profile.php`, just didn't work for me. I have a ...
`wp_get_current_user()` returns an object. `update_user_meta( $user_id, $meta_key, $meta_value, $prev_value` ) accepts `user_id` as first parameter. Use the following code to get user ID from `wp_get_current_user()` ``` update_user_meta( $user->ID, 'custom_user_fields', $userData ); ```
236,465
<p>I have been searching for hours trying to find a way to test the update process for my plugin before tagging a new release in the repo. I have a function that is called using <code>add_action( 'upgrader_process_complete', 'my_plugin_upgrade_function', 10, 2);</code> and I can't figure out how to test this prior to r...
[ { "answer_id": 236458, "author": "Aamer Shahzad", "author_id": 42772, "author_profile": "https://wordpress.stackexchange.com/users/42772", "pm_score": 1, "selected": true, "text": "<p><code>wp_get_current_user()</code> returns an object. <code>update_user_meta( $user_id, $meta_key, $meta...
2016/08/19
[ "https://wordpress.stackexchange.com/questions/236465", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47422/" ]
I have been searching for hours trying to find a way to test the update process for my plugin before tagging a new release in the repo. I have a function that is called using `add_action( 'upgrader_process_complete', 'my_plugin_upgrade_function', 10, 2);` and I can't figure out how to test this prior to release. Any h...
`wp_get_current_user()` returns an object. `update_user_meta( $user_id, $meta_key, $meta_value, $prev_value` ) accepts `user_id` as first parameter. Use the following code to get user ID from `wp_get_current_user()` ``` update_user_meta( $user->ID, 'custom_user_fields', $userData ); ```
236,514
<h3>Objective</h3> <p>As all plugin developer, I want to delete all options that begin with the same prefix.</p> <h3>Backstory</h3> <p>I've developed a plugin that stores data in the options. When the user uninstalls the plugin, the <code>uninstall.php</code> in the plugin executes the following code:</p> <pre><code>if...
[ { "answer_id": 236515, "author": "Nate Allen", "author_id": 32698, "author_profile": "https://wordpress.stackexchange.com/users/32698", "pm_score": 3, "selected": false, "text": "<p>Replace \"myplugin_\" with your prefix:</p>\n\n<pre><code>global $wpdb;\n\n$plugin_options = $wpdb-&gt;get...
2016/08/20
[ "https://wordpress.stackexchange.com/questions/236514", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98212/" ]
### Objective As all plugin developer, I want to delete all options that begin with the same prefix. ### Backstory I've developed a plugin that stores data in the options. When the user uninstalls the plugin, the `uninstall.php` in the plugin executes the following code: ``` if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )...
I've found out another alternative by using the [`wp_load_alloptions()`](https://codex.wordpress.org/Function_Reference/wp_load_alloptions) function to get all of the available options, then `delete_option()` for every option that has the `myplugin_` prefix: ``` foreach ( wp_load_alloptions() as $option => $value ) { ...
236,530
<p>I am using <code>&lt;!--nextpage--&gt;</code> to break my posts on multiple pages. This is working fine. But I want to further change the page numbering. </p> <p>If you visit <a href="http://mycitymychoice.com/fruit-9-letters/" rel="nofollow">this post</a> you will note the page breaks. I want to change the first p...
[ { "answer_id": 236531, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>The example in the codex has faulty quotation marks. The developer area has more detail on how to use <a href=\"...
2016/08/20
[ "https://wordpress.stackexchange.com/questions/236530", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101334/" ]
I am using `<!--nextpage-->` to break my posts on multiple pages. This is working fine. But I want to further change the page numbering. If you visit [this post](http://mycitymychoice.com/fruit-9-letters/) you will note the page breaks. I want to change the first page to "Question" while the second page to "Answer" ...
Put this function in you `functions.php` - ``` function the_dramatist_wp_link_pages( $args = '' ) { global $page, $numpages, $multipage, $more; $defaults = array( 'before' => '<p>' . __( 'Pages:' ), 'after' => '</p>', 'link_before' => '', 'link_after' ...
236,533
<p>I am trying to write update query where id is not equal to 5</p> <p>i want output like this but not working.</p> <pre><code>UPDATE `wp_messg` SET `is_read` = 1 WHERE `job_id` = 1 AND `biv_id`!=5 $id=5; $wpdb-&gt;update( 'wp_messg', array( 'is_read' =&gt; 1, // string ...
[ { "answer_id": 236554, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 0, "selected": false, "text": "<p>It is not possible to use <code>NOT EQUAL</code> in <code>$wpdb-&gt;update()</code>. Here look the source ...
2016/08/20
[ "https://wordpress.stackexchange.com/questions/236533", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54905/" ]
I am trying to write update query where id is not equal to 5 i want output like this but not working. ``` UPDATE `wp_messg` SET `is_read` = 1 WHERE `job_id` = 1 AND `biv_id`!=5 $id=5; $wpdb->update( 'wp_messg', array( 'is_read' => 1, // string ), array( 'job_i...
This is not something `$wpdb->update()` method implements. If you have custom SQL query that cannot be expressed in API you can run it as is with generic `$wpdb->query()`.
236,534
<p>I'm currently building a pretty straightforward plugin, but it relies quite extensively on AJAX requests. I'm using the standard <code>admin-ajax</code> endpoint for the requests, but I find that it seems to be massively inconsistent, sometimes the request (for the same data) will take a few hundred milliseconds and...
[ { "answer_id": 236552, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>The main problem with native ajax endpoint is that it has to <em>load whole WordPress core</em>. Unless something i...
2016/08/20
[ "https://wordpress.stackexchange.com/questions/236534", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85542/" ]
I'm currently building a pretty straightforward plugin, but it relies quite extensively on AJAX requests. I'm using the standard `admin-ajax` endpoint for the requests, but I find that it seems to be massively inconsistent, sometimes the request (for the same data) will take a few hundred milliseconds and then sometime...
Use [`add_rewrite_rule`](https://codex.wordpress.org/Rewrite_API/add_rewrite_rule) to make your own API and handle the endpoints yourself. Tools like [Monkeyman Rewrite Analyzer](https://wordpress.org/plugins/monkeyman-rewrite-analyzer/) will help you understand how your rewrite rules end up working with existing rule...
236,539
<p>I need help with WP custom taxonomy and custom post types. I never find a working solution so far. Please accept my apologies if this has a simple solution. I tried my best to find solution everywhere first.</p> <p>Explanation of issue -</p> <ol> <li>I have one taxonomy called <strong>"department"</strong>.</li> <...
[ { "answer_id": 236546, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 0, "selected": false, "text": "<p>Please try this-</p>\n\n<pre><code>$post_type = array('course', 'faculty', 'library');\n$terms = array( 'x...
2016/08/20
[ "https://wordpress.stackexchange.com/questions/236539", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65847/" ]
I need help with WP custom taxonomy and custom post types. I never find a working solution so far. Please accept my apologies if this has a simple solution. I tried my best to find solution everywhere first. Explanation of issue - 1. I have one taxonomy called **"department"**. 2. I have 3 CPT called **"course", "fac...
WP defaults to showing normal native Posts in archives. It won't automagically pick up *which* post types you want in your archive. You will have to adjust main query for it to explain that to it, with something like: ``` add_action( 'pre_get_posts', function ( WP_Query $query ) { if ( $query->is_main_query() &&...
236,576
<p>I have a simple two columns website (one sidebar + one maincoulmn). In the sidebar area I use this code to show some post thumbnails:</p> <pre><code>&lt;?php the_post_thumbnail('custom-size-small' ,array('class' =&gt; 'image', 'title' =&gt; strip_tags(get_the_title()), 'itemprop' =&gt; 'image')); ?&gt; </code></pre...
[ { "answer_id": 236579, "author": "Ladislav Janeček", "author_id": 50964, "author_profile": "https://wordpress.stackexchange.com/users/50964", "pm_score": -1, "selected": false, "text": "<p>You can add to CSS this code:</p>\n\n<pre><code>.image {\n max-width: 100%;\n width: auto;\n ...
2016/08/21
[ "https://wordpress.stackexchange.com/questions/236576", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101351/" ]
I have a simple two columns website (one sidebar + one maincoulmn). In the sidebar area I use this code to show some post thumbnails: ``` <?php the_post_thumbnail('custom-size-small' ,array('class' => 'image', 'title' => strip_tags(get_the_title()), 'itemprop' => 'image')); ?> ``` My website is responsive and on sma...
This is mostly off-topic, but your assumption that `srcset` is somehow related to going desktop => mobile is just false. the `srcset` attribute notifies the browser about alternative images and sizes and it is **the browser that selects which image to use** based on whatever criteria it wants. Therefor there is most li...
236,591
<p>Can anyone tell me what the correct syntax is for the following?</p> <pre><code>&lt;?php if (function_exists('z_taxonomy_image')) : ?&gt; &lt;img alt="" src="&lt;?php if (function_exists('z_taxonomy_image_url')) echo z_taxonomy_image_url($child-&gt;term_id);?&gt;" /&gt; &lt;?php else : ?&gt; ...
[ { "answer_id": 236579, "author": "Ladislav Janeček", "author_id": 50964, "author_profile": "https://wordpress.stackexchange.com/users/50964", "pm_score": -1, "selected": false, "text": "<p>You can add to CSS this code:</p>\n\n<pre><code>.image {\n max-width: 100%;\n width: auto;\n ...
2016/08/21
[ "https://wordpress.stackexchange.com/questions/236591", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68414/" ]
Can anyone tell me what the correct syntax is for the following? ``` <?php if (function_exists('z_taxonomy_image')) : ?> <img alt="" src="<?php if (function_exists('z_taxonomy_image_url')) echo z_taxonomy_image_url($child->term_id);?>" /> <?php else : ?> echo '<img alt="'. esc_html( get_the_...
This is mostly off-topic, but your assumption that `srcset` is somehow related to going desktop => mobile is just false. the `srcset` attribute notifies the browser about alternative images and sizes and it is **the browser that selects which image to use** based on whatever criteria it wants. Therefor there is most li...
236,600
<p>I have a custom post type called event. The URL structure looks like this. </p> <blockquote> <p><a href="http://my-url.com/events/2016/08/21/workshop" rel="nofollow">http://my-url.com/events/2016/08/21/workshop</a></p> </blockquote> <p>Where "workshop" is the name of the event. Right now the template will show d...
[ { "answer_id": 236612, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 2, "selected": false, "text": "<p>Put this code in your <code>functions.php</code>-</p>\n\n<pre><code>function the_dramatist_url_rewrite() {...
2016/08/21
[ "https://wordpress.stackexchange.com/questions/236600", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16567/" ]
I have a custom post type called event. The URL structure looks like this. > > <http://my-url.com/events/2016/08/21/workshop> > > > Where "workshop" is the name of the event. Right now the template will show different data depending on the query string. For example this URL: > > <http://my-url.com/events/2016/...
I ended up using [end points](https://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint). This is my final (but simplified) code. In functions i added this. ``` add_action('init', 'jbenjaminsson_add_endpoints'); function jbenjaminsson_add_endpoints() { add_rewrite_endpoint( 'files', EP_PERMALINK ); add_rewr...
236,626
<p>I have used the following code to display the featured image for each post, but nothing is showing:</p> <pre><code> &lt;div class="thumbnail-img"&gt; &lt;?php $lastBlog = new WP_Query('type=post&amp;posts_per_page=2&amp;offset=1'); if ($lastBlog-&gt;has_post_thumbnail()) { wh...
[ { "answer_id": 236629, "author": "Ali Basheer", "author_id": 93545, "author_profile": "https://wordpress.stackexchange.com/users/93545", "pm_score": 1, "selected": false, "text": "<p>I use this way:</p>\n\n<pre><code>$args = array ( 'post_type' =&gt; 'slider');\n$slides = get_posts( $arg...
2016/08/21
[ "https://wordpress.stackexchange.com/questions/236626", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101377/" ]
I have used the following code to display the featured image for each post, but nothing is showing: ``` <div class="thumbnail-img"> <?php $lastBlog = new WP_Query('type=post&posts_per_page=2&offset=1'); if ($lastBlog->has_post_thumbnail()) { while($lastBlog->has_post_thumbnail()) ...
``` <div class="thumbnail-img"> <?php $lastBlog = new WP_Query('post_type=post&posts_per_page=2'); if ($lastBlog->have_posts()) { while($lastBlog->have_posts()) { $lastBlog->the_post(); if(has_post_thumbnail()){ the_post_thumbnail(); } ...
236,646
<p>In plugin development, how to fetch data from database of particular data in dropdown list?</p> <pre><code>global $wpdb; $id = 'parent_id'; $data = $wpdb-&gt;get_results("SELECT * FROM wp_postmeta WHERE meta_key = $id"); echo $data; </code></pre> <p>i get results as array how can i get all values in dropdown list...
[ { "answer_id": 236629, "author": "Ali Basheer", "author_id": 93545, "author_profile": "https://wordpress.stackexchange.com/users/93545", "pm_score": 1, "selected": false, "text": "<p>I use this way:</p>\n\n<pre><code>$args = array ( 'post_type' =&gt; 'slider');\n$slides = get_posts( $arg...
2016/08/22
[ "https://wordpress.stackexchange.com/questions/236646", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101387/" ]
In plugin development, how to fetch data from database of particular data in dropdown list? ``` global $wpdb; $id = 'parent_id'; $data = $wpdb->get_results("SELECT * FROM wp_postmeta WHERE meta_key = $id"); echo $data; ``` i get results as array how can i get all values in dropdown list? Can you please help?
``` <div class="thumbnail-img"> <?php $lastBlog = new WP_Query('post_type=post&posts_per_page=2'); if ($lastBlog->have_posts()) { while($lastBlog->have_posts()) { $lastBlog->the_post(); if(has_post_thumbnail()){ the_post_thumbnail(); } ...
236,705
<p>How to remove this from WP head:</p> <pre><code>&lt;link rel='dns-prefetch' href='//maps.google.com'&gt; </code></pre> <p>I had this also:</p> <pre><code>&lt;link rel='dns-prefetch' href='//s.w.org'&gt; </code></pre> <p>But, I removed it with this code inside my functions.php</p> <pre><code>add_filter( 'emoji_s...
[ { "answer_id": 236708, "author": "wpclevel", "author_id": 92212, "author_profile": "https://wordpress.stackexchange.com/users/92212", "pm_score": 4, "selected": true, "text": "<p><a href=\"https://make.wordpress.org/core/2016/07/06/resource-hints-in-4-6/\" rel=\"noreferrer\">Resource Hin...
2016/08/22
[ "https://wordpress.stackexchange.com/questions/236705", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25053/" ]
How to remove this from WP head: ``` <link rel='dns-prefetch' href='//maps.google.com'> ``` I had this also: ``` <link rel='dns-prefetch' href='//s.w.org'> ``` But, I removed it with this code inside my functions.php ``` add_filter( 'emoji_svg_url', '__return_false' ); ``` Probably, this is added by one plugi...
[Resource Hints](https://make.wordpress.org/core/2016/07/06/resource-hints-in-4-6/) is a smart feature added to WordPress version 4.6. I think it might improve your site speed. But if you want to disable it, try this: ``` remove_action('wp_head', 'wp_resource_hints', 2); ``` --- **References** * [wp\_head resource...
236,718
<p>I was developing website on <code>test.example.com</code> on a separate server. Meanwhile, the working server was <code>example.com</code> at GoDaddy.</p> <p>The WordPress website was working fine on both servers. But then I changed the registrar and decided to change the WordPress on <code>test.example.com</code> ...
[ { "answer_id": 236708, "author": "wpclevel", "author_id": 92212, "author_profile": "https://wordpress.stackexchange.com/users/92212", "pm_score": 4, "selected": true, "text": "<p><a href=\"https://make.wordpress.org/core/2016/07/06/resource-hints-in-4-6/\" rel=\"noreferrer\">Resource Hin...
2016/08/22
[ "https://wordpress.stackexchange.com/questions/236718", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101428/" ]
I was developing website on `test.example.com` on a separate server. Meanwhile, the working server was `example.com` at GoDaddy. The WordPress website was working fine on both servers. But then I changed the registrar and decided to change the WordPress on `test.example.com` to `example.com` inside of the `wp-config.p...
[Resource Hints](https://make.wordpress.org/core/2016/07/06/resource-hints-in-4-6/) is a smart feature added to WordPress version 4.6. I think it might improve your site speed. But if you want to disable it, try this: ``` remove_action('wp_head', 'wp_resource_hints', 2); ``` --- **References** * [wp\_head resource...
236,723
<p>I'm new to wordpress/php and I'm trying to create new posts dynamically through a xml file.</p> <p>The xml I'm working with is this <a href="http://videos.oneupsports.com/oneup-sports-national/rss.xml" rel="nofollow">one</a>.</p> <p>The file get updated periodically during the day in a FILO fashion (new item are a...
[ { "answer_id": 236708, "author": "wpclevel", "author_id": 92212, "author_profile": "https://wordpress.stackexchange.com/users/92212", "pm_score": 4, "selected": true, "text": "<p><a href=\"https://make.wordpress.org/core/2016/07/06/resource-hints-in-4-6/\" rel=\"noreferrer\">Resource Hin...
2016/08/22
[ "https://wordpress.stackexchange.com/questions/236723", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101431/" ]
I'm new to wordpress/php and I'm trying to create new posts dynamically through a xml file. The xml I'm working with is this [one](http://videos.oneupsports.com/oneup-sports-national/rss.xml). The file get updated periodically during the day in a FILO fashion (new item are added at the top and the bottom one get push...
[Resource Hints](https://make.wordpress.org/core/2016/07/06/resource-hints-in-4-6/) is a smart feature added to WordPress version 4.6. I think it might improve your site speed. But if you want to disable it, try this: ``` remove_action('wp_head', 'wp_resource_hints', 2); ``` --- **References** * [wp\_head resource...
236,734
<p>I've done this many times before, and yet I'm not managing to do this again for some unknown reason. Tried endless solutions. Everything I've tried results in an endless redirect loop. </p> <p>What is the best option for doing this?</p> <p><strong>Update 1</strong> Here are a few of the things tried;</p> <pre><co...
[ { "answer_id": 236851, "author": "Ethan O'Sullivan", "author_id": 98212, "author_profile": "https://wordpress.stackexchange.com/users/98212", "pm_score": 5, "selected": true, "text": "<p>I see, when you enter a link to your page other than your home, example:</p>\n\n<ul>\n<li><code>http:...
2016/08/22
[ "https://wordpress.stackexchange.com/questions/236734", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/91911/" ]
I've done this many times before, and yet I'm not managing to do this again for some unknown reason. Tried endless solutions. Everything I've tried results in an endless redirect loop. What is the best option for doing this? **Update 1** Here are a few of the things tried; ``` RewriteCond %{HTTP_HOST} ^website\.co\...
I see, when you enter a link to your page other than your home, example: * `http://www.michaelcropper.co.uk/contact-me` * `www.michaelcropper.co.uk/contact-me` * `michaelcropper.co.uk/contact-me` If `https://` is not in the prefix, the HTTP link loads instead. Add the following into your `.htaccess` in between the `<...
236,739
<p>After severall search, maybe without the right english terms, I come here to find an answer to my problem.</p> <p>I have a theme that I created on my website, everything is working perfectly for the last 6 months.</p> <p>I also have a custom post type to add some twitch channel on my website and display them.</p> ...
[ { "answer_id": 236851, "author": "Ethan O'Sullivan", "author_id": 98212, "author_profile": "https://wordpress.stackexchange.com/users/98212", "pm_score": 5, "selected": true, "text": "<p>I see, when you enter a link to your page other than your home, example:</p>\n\n<ul>\n<li><code>http:...
2016/08/22
[ "https://wordpress.stackexchange.com/questions/236739", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101437/" ]
After severall search, maybe without the right english terms, I come here to find an answer to my problem. I have a theme that I created on my website, everything is working perfectly for the last 6 months. I also have a custom post type to add some twitch channel on my website and display them. Yesterday, I created...
I see, when you enter a link to your page other than your home, example: * `http://www.michaelcropper.co.uk/contact-me` * `www.michaelcropper.co.uk/contact-me` * `michaelcropper.co.uk/contact-me` If `https://` is not in the prefix, the HTTP link loads instead. Add the following into your `.htaccess` in between the `<...
236,745
<p>I'm trying to move a Wordpress installation in a web hosting to a localhost installation for development. I followed <a href="http://www.wpbeginner.com/wp-tutorials/how-to-move-live-wordpress-site-to-local-server/" rel="nofollow">this tutorial</a> (Section <em>Manually Move a Live WordPress Site to Local Server</em>...
[ { "answer_id": 236851, "author": "Ethan O'Sullivan", "author_id": 98212, "author_profile": "https://wordpress.stackexchange.com/users/98212", "pm_score": 5, "selected": true, "text": "<p>I see, when you enter a link to your page other than your home, example:</p>\n\n<ul>\n<li><code>http:...
2016/08/23
[ "https://wordpress.stackexchange.com/questions/236745", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100952/" ]
I'm trying to move a Wordpress installation in a web hosting to a localhost installation for development. I followed [this tutorial](http://www.wpbeginner.com/wp-tutorials/how-to-move-live-wordpress-site-to-local-server/) (Section *Manually Move a Live WordPress Site to Local Server*, for now I'm not allowed to install...
I see, when you enter a link to your page other than your home, example: * `http://www.michaelcropper.co.uk/contact-me` * `www.michaelcropper.co.uk/contact-me` * `michaelcropper.co.uk/contact-me` If `https://` is not in the prefix, the HTTP link loads instead. Add the following into your `.htaccess` in between the `<...
236,761
<p>I've tried </p> <pre><code>&lt;?php $trimmed = wp_trim_words( get_the_content(), 55, "" ); ?&gt; &lt;?php echo $trimmed; ?&gt; </code></pre> <p>and </p> <pre><code>&lt;?php $trimmed = wp_trim_words( the_content(), 55, "" ); ?&gt; &lt;?php echo $trimmed; ?&gt; </code></pre> <p>the second option with <code>the_con...
[ { "answer_id": 236775, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 1, "selected": false, "text": "<p>Well, as far I understood you want to remove all the HTML tags from the trimmed <code>the_content</code>. ...
2016/08/23
[ "https://wordpress.stackexchange.com/questions/236761", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82731/" ]
I've tried ``` <?php $trimmed = wp_trim_words( get_the_content(), 55, "" ); ?> <?php echo $trimmed; ?> ``` and ``` <?php $trimmed = wp_trim_words( the_content(), 55, "" ); ?> <?php echo $trimmed; ?> ``` the second option with `the_content` does not work as expected. Some posts have a video in the content and w...
Well, as far I understood you want to remove all the HTML tags from the trimmed `the_content`. Right??? Try `wp_filter_nohtml_kses` function. Hope that's going to work. Here is the full code- ``` <?php $trimmed = wp_filter_nohtml_kses( wp_trim_words( get_the_content(), 55, "" ) ); ?> <?php echo $trimmed; ?> ```
236,804
<p>I am adding the below code for the email notification when my wordpress site fas fatal error or other. But I am not getting the email when I rename the load.php file(i.e when fatal error occurs)</p> <pre><code>do_action( 'shutdown', $array ); function action_shutdown($array) { $err = error_get_last(); if ( !$err) {...
[ { "answer_id": 236825, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>I think you are misusing <code>shutdown</code> hook. WP attaches it to use with <code>register_shutdown_function()<...
2016/08/23
[ "https://wordpress.stackexchange.com/questions/236804", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101207/" ]
I am adding the below code for the email notification when my wordpress site fas fatal error or other. But I am not getting the email when I rename the load.php file(i.e when fatal error occurs) ``` do_action( 'shutdown', $array ); function action_shutdown($array) { $err = error_get_last(); if ( !$err) { return; } $fa...
I think you are misusing `shutdown` hook. WP attaches it to use with `register_shutdown_function()` and it's meant to process end of script execution, not log/process errors. If you want to handle errors in a custom way you are better off using generic PHP `set_error_handler()` which is meant for that.
236,812
<p>I just put my website on the Web and noticed that the menu is not really working.Nothing happens when I click on it and when Inspect the element s I actually don't see the scripts. All works perfectly in the localhost though.</p> <p>Here my function.php:</p> <pre><code>function scentology_scripts() { wp_...
[ { "answer_id": 236819, "author": "Aftab", "author_id": 64614, "author_profile": "https://wordpress.stackexchange.com/users/64614", "pm_score": -1, "selected": false, "text": "<p>You need to add your jquery.js file first and then enqueue rest of the JS file.</p>\n\n<p>Updated code : </p>\...
2016/08/23
[ "https://wordpress.stackexchange.com/questions/236812", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99178/" ]
I just put my website on the Web and noticed that the menu is not really working.Nothing happens when I click on it and when Inspect the element s I actually don't see the scripts. All works perfectly in the localhost though. Here my function.php: ``` function scentology_scripts() { wp_enqueue_style( 'scento...
I dont really see anything wrong on what I did previously. But in any case I changed the name of the file to navbar.js and then my functions.php looked like this: ``` function scentology_scripts() { wp_enqueue_style( 'scentology-local-fonts', get_template_directory_uri() . '/fonts/raleway.css' ); wp_enqueue_st...
236,814
<p>I wonder how can finde html/php source to change , word name from Read More to just More.</p> <p><a href="http://www.wyprawykulturowe.pl/2016/08/17/tropikalna-wyspa/" rel="nofollow">http://www.wyprawykulturowe.pl/2016/08/17/tropikalna-wyspa/</a></p> <p>This is the site this image block on bottom have some descript...
[ { "answer_id": 236819, "author": "Aftab", "author_id": 64614, "author_profile": "https://wordpress.stackexchange.com/users/64614", "pm_score": -1, "selected": false, "text": "<p>You need to add your jquery.js file first and then enqueue rest of the JS file.</p>\n\n<p>Updated code : </p>\...
2016/08/23
[ "https://wordpress.stackexchange.com/questions/236814", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93972/" ]
I wonder how can finde html/php source to change , word name from Read More to just More. <http://www.wyprawykulturowe.pl/2016/08/17/tropikalna-wyspa/> This is the site this image block on bottom have some description and of end of it is Read More that i wanna change to just More . How can i do it? THanks!
I dont really see anything wrong on what I did previously. But in any case I changed the name of the file to navbar.js and then my functions.php looked like this: ``` function scentology_scripts() { wp_enqueue_style( 'scentology-local-fonts', get_template_directory_uri() . '/fonts/raleway.css' ); wp_enqueue_st...
236,816
<p>I want to add the currenty category to the body class.</p> <p>How do I need to modify my current code, to add also the current category as a body class to the <code>is_singular( 'knowledgebase' )</code> section?</p> <p>My current code looks like this:</p> <pre><code>function add_body_class( $classes ) { glob...
[ { "answer_id": 236819, "author": "Aftab", "author_id": 64614, "author_profile": "https://wordpress.stackexchange.com/users/64614", "pm_score": -1, "selected": false, "text": "<p>You need to add your jquery.js file first and then enqueue rest of the JS file.</p>\n\n<p>Updated code : </p>\...
2016/08/23
[ "https://wordpress.stackexchange.com/questions/236816", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101477/" ]
I want to add the currenty category to the body class. How do I need to modify my current code, to add also the current category as a body class to the `is_singular( 'knowledgebase' )` section? My current code looks like this: ``` function add_body_class( $classes ) { global $pakb; if( is_page( $pakb->get(...
I dont really see anything wrong on what I did previously. But in any case I changed the name of the file to navbar.js and then my functions.php looked like this: ``` function scentology_scripts() { wp_enqueue_style( 'scentology-local-fonts', get_template_directory_uri() . '/fonts/raleway.css' ); wp_enqueue_st...
236,834
<p>I'm looking to create a very simple contact for that I can output with a shortcode. I have the following code, but it doesn't seem to validate properly and even lets you submit the form without inputting any details. Any chance someone could explain how to validate the form please. I would also like to add a honey p...
[ { "answer_id": 236836, "author": "Greg McMullen", "author_id": 36028, "author_profile": "https://wordpress.stackexchange.com/users/36028", "pm_score": 0, "selected": false, "text": "<p>Since you are somewhat new to PHP, here's a nice example of a <a href=\"http://devgrow.com/simple-php-h...
2016/08/23
[ "https://wordpress.stackexchange.com/questions/236834", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98778/" ]
I'm looking to create a very simple contact for that I can output with a shortcode. I have the following code, but it doesn't seem to validate properly and even lets you submit the form without inputting any details. Any chance someone could explain how to validate the form please. I would also like to add a honey pot ...
You don't have any validation mechanism. Your logic should be somewhat along those lines * Submit form * Check submitted fields ($\_POST) against expected values * If all looks good send * If something is not as expected, log error ( you can use WP\_Error() ) and rebuild form showing error message (and maybe repopul...
236,841
<p>I want to do a small game for the users of my WP site. The game itself will <em>only</em> use the authentication system from WP, but all of its other logic is entirely external.</p> <p>Right now, if I use a standard WordPress page with a custom template (embedding my game's PHP script) it loads, but seems to load t...
[ { "answer_id": 237848, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 2, "selected": false, "text": "<p>Not sure, but currently in my mind the first solution. Do you need the data from WordPress for the authentication...
2016/08/23
[ "https://wordpress.stackexchange.com/questions/236841", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101488/" ]
I want to do a small game for the users of my WP site. The game itself will *only* use the authentication system from WP, but all of its other logic is entirely external. Right now, if I use a standard WordPress page with a custom template (embedding my game's PHP script) it loads, but seems to load too slowly for my ...
Not sure, but currently in my mind the first solution. Do you need the data from WordPress for the authentication. If you include the `wp-load.php` you have access to WordPress and his functions, maybe to identifier. But the file to include as static path is not really great and solid. ``` define( 'WP_USE_THEMES', FAL...
236,866
<p>I tried use wp-cli theme install with option url from my dropbox link. But unfortunately, I got this problem:</p> <p>PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature</p> <p>This mean my zip file is corrupt. But I tried upload it through wordpress dashboard and it's work good. I trie...
[ { "answer_id": 237848, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 2, "selected": false, "text": "<p>Not sure, but currently in my mind the first solution. Do you need the data from WordPress for the authentication...
2016/08/23
[ "https://wordpress.stackexchange.com/questions/236866", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57367/" ]
I tried use wp-cli theme install with option url from my dropbox link. But unfortunately, I got this problem: PCLZIP\_ERR\_BAD\_FORMAT (-10) : Unable to find End of Central Dir Record signature This mean my zip file is corrupt. But I tried upload it through wordpress dashboard and it's work good. I tried again with f...
Not sure, but currently in my mind the first solution. Do you need the data from WordPress for the authentication. If you include the `wp-load.php` you have access to WordPress and his functions, maybe to identifier. But the file to include as static path is not really great and solid. ``` define( 'WP_USE_THEMES', FAL...
236,873
<p>Ok, so I have created a custom post type and installed the relevant REST plugins and I have a working JSON feed. </p> <p>What do I do next?</p> <p>Basically, I would like to display a portion of the JSON feed on an existing wordpress page, a bit like doing a <code>wp_query</code> I suppose.</p> <p>Can this be don...
[ { "answer_id": 237256, "author": "Jesús Franco", "author_id": 16301, "author_profile": "https://wordpress.stackexchange.com/users/16301", "pm_score": 1, "selected": false, "text": "<p>Unfortunately I don't know Angular to give you a hand with that, but I'm seeing this question is related...
2016/08/23
[ "https://wordpress.stackexchange.com/questions/236873", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40727/" ]
Ok, so I have created a custom post type and installed the relevant REST plugins and I have a working JSON feed. What do I do next? Basically, I would like to display a portion of the JSON feed on an existing wordpress page, a bit like doing a `wp_query` I suppose. Can this be done with AngularJS ? I haven't been a...
Unfortunately I don't know Angular to give you a hand with that, but I'm seeing this question is related to another about [consuming an endpoint with a filter by meta\_key](https://wordpress.stackexchange.com/questions/237167/create-filtered-list-of-posts-using-json-data) (by the way, I've updated my previous response ...
236,881
<p>I am currently running an instance of WordPress, version 4.5.3, on an Amazon EC2 server. It uses:</p> <ul> <li>CentOS 7 (OS) and has SELinux enabled.</li> <li>Server runs Apache with <code>mod_security</code> and <code>mod_evasive</code></li> <li>PHP 5.6.24</li> </ul> <p>The site's name is <a href="https://www.ram...
[ { "answer_id": 237256, "author": "Jesús Franco", "author_id": 16301, "author_profile": "https://wordpress.stackexchange.com/users/16301", "pm_score": 1, "selected": false, "text": "<p>Unfortunately I don't know Angular to give you a hand with that, but I'm seeing this question is related...
2016/08/23
[ "https://wordpress.stackexchange.com/questions/236881", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101506/" ]
I am currently running an instance of WordPress, version 4.5.3, on an Amazon EC2 server. It uses: * CentOS 7 (OS) and has SELinux enabled. * Server runs Apache with `mod_security` and `mod_evasive` * PHP 5.6.24 The site's name is [The Rambling New Yorker](https://www.ramblingnewyorker.com/). Not long ago I upgraded...
Unfortunately I don't know Angular to give you a hand with that, but I'm seeing this question is related to another about [consuming an endpoint with a filter by meta\_key](https://wordpress.stackexchange.com/questions/237167/create-filtered-list-of-posts-using-json-data) (by the way, I've updated my previous response ...
236,883
<p>I have a custom post type registered called <code>employees</code>. When registering this custom post type I used:</p> <pre><code>... 'rewrite' =&gt; array('slug' =&gt; 'people'), ... </code></pre> <p>Now, when I hover over a link to one of my employees I see the url as this:</p> <pre><code>www.example.com/people...
[ { "answer_id": 236884, "author": "Thomas", "author_id": 101453, "author_profile": "https://wordpress.stackexchange.com/users/101453", "pm_score": 1, "selected": false, "text": "<p>if you have register your taxo with\nregister_post_type('employees',$args);</p>\n\n<p>have you create single...
2016/08/23
[ "https://wordpress.stackexchange.com/questions/236883", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8160/" ]
I have a custom post type registered called `employees`. When registering this custom post type I used: ``` ... 'rewrite' => array('slug' => 'people'), ... ``` Now, when I hover over a link to one of my employees I see the url as this: ``` www.example.com/people/john ``` So that seems correct. But I click the lin...
The most important args for rewrite redirects when registering new post type are: * 'public' => true, * 'publicly\_queryable' => true, * 'query\_var' => true, **I have pasted some code below which I have tested and it working fine for the url : www.example.com/people/john** ``` $labels_employee = array('name' ...
236,947
<p>I've created a custom category template to display the current category's child categories instead of posts. Child categories are displayed via a custom thumbnail, title and category description.</p> <p>I have added a function to trim the category description to a predefined number of characters, but I'm not sure w...
[ { "answer_id": 236891, "author": "Zareef Ahmed", "author_id": 101508, "author_profile": "https://wordpress.stackexchange.com/users/101508", "pm_score": 0, "selected": false, "text": "<p>From error message it seems that something is wrong with cookie system. have you tried using another b...
2016/08/24
[ "https://wordpress.stackexchange.com/questions/236947", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68414/" ]
I've created a custom category template to display the current category's child categories instead of posts. Child categories are displayed via a custom thumbnail, title and category description. I have added a function to trim the category description to a predefined number of characters, but I'm not sure which actio...
Looks like the issue was because of Nginx or other caching server. Rebooting the server solved the issue! There was nothing more to do in the database or `wp-config.php`
237,001
<p>For some reason I'm not able to retrieve any child terms for the <code>carabana_cat</code> taxonomy. Here's what I've done so far:</p> <pre><code>$custom_terms = get_terms( 'carabana_Cat', array( 'hide_empty' =&gt; false, 'orderly' =&gt; 'description', 'child_of' =&gt; 28) ); </code></pre> <p>What am I doing wrong...
[ { "answer_id": 237000, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>There are really two questions here 1. what is the impact of having an hook? and 2. Should you just sprea...
2016/08/24
[ "https://wordpress.stackexchange.com/questions/237001", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101581/" ]
For some reason I'm not able to retrieve any child terms for the `carabana_cat` taxonomy. Here's what I've done so far: ``` $custom_terms = get_terms( 'carabana_Cat', array( 'hide_empty' => false, 'orderly' => 'description', 'child_of' => 28) ); ``` What am I doing wrong here? There are lots of child terms for `id=2...
As long as hooks don't have anything hooked to them they are no-ops, that is do nearly nothing and have no considerable effect on runtime. It gets quite different when things *are* hooked and there are *a lot* of calls. Since you talk about customizing strings the good example would be `gettext` hook in core. Every st...
237,009
<p>Each widget has a row in the <code>options</code> table with values for title and other fields. Is there any way we can update those values outside the <code>update</code> function?</p> <p>For example, here are some values for a sample widget: </p> <pre><code>a:2:{i:2;a:23:{s:5:"title";s:19:"Widget Title";..... </...
[ { "answer_id": 237000, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>There are really two questions here 1. what is the impact of having an hook? and 2. Should you just sprea...
2016/08/24
[ "https://wordpress.stackexchange.com/questions/237009", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82260/" ]
Each widget has a row in the `options` table with values for title and other fields. Is there any way we can update those values outside the `update` function? For example, here are some values for a sample widget: ``` a:2:{i:2;a:23:{s:5:"title";s:19:"Widget Title";..... ``` now I want to update the `title` to ano...
As long as hooks don't have anything hooked to them they are no-ops, that is do nearly nothing and have no considerable effect on runtime. It gets quite different when things *are* hooked and there are *a lot* of calls. Since you talk about customizing strings the good example would be `gettext` hook in core. Every st...
237,020
<p>I am attempting to add a data attribute to all menu items, but it's simply not working. I am using <code>wp_nav_menu</code> to call my menu walker as well.</p> <pre><code>function menu_anchor_attributes ( $atts, $item, $args ) { $atts['data-menuanchor'] = $item-&gt;attr_title; return $atts; } add_filter( 'nav_m...
[ { "answer_id": 237494, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 1, "selected": false, "text": "<p>Whenever an attribute is empty WordPress filters decide just not to show the attribute so a simple test for...
2016/08/24
[ "https://wordpress.stackexchange.com/questions/237020", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101588/" ]
I am attempting to add a data attribute to all menu items, but it's simply not working. I am using `wp_nav_menu` to call my menu walker as well. ``` function menu_anchor_attributes ( $atts, $item, $args ) { $atts['data-menuanchor'] = $item->attr_title; return $atts; } add_filter( 'nav_menu_link_attributes', 'menu_...
Whenever an attribute is empty WordPress filters decide just not to show the attribute so a simple test for this is the following: ``` function menu_anchor_attributes ( $atts, $item, $args ) { $atts['data-menuanchor'] = ( ! empty( $item->attr_title ) ) ? $item->attr_title : 'test'; return $atts; } add_filter( ...
237,023
<p>Learning more about sessions I've gathered that a <code>session_start()</code> should come directly after <code>&lt;?php</code> per <a href="https://stackoverflow.com/questions/20308478/where-exactly-do-i-put-a-session-start">Where exactly do I put a SESSION_START?</a> and I wanted to play around and create a plugin...
[ { "answer_id": 237034, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>There is no regular output and hence no header sent before <code>template_redirect</code> on the front end. If you nee...
2016/08/24
[ "https://wordpress.stackexchange.com/questions/237023", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25271/" ]
Learning more about sessions I've gathered that a `session_start()` should come directly after `<?php` per [Where exactly do I put a SESSION\_START?](https://stackoverflow.com/questions/20308478/where-exactly-do-i-put-a-session-start) and I wanted to play around and create a plugin that would add a `session_start()` to...
There is no regular output and hence no header sent before `template_redirect` on the front end. If you need sessions on the back end too, use the action `wp_loaded` to cover both. Example: ``` add_action( 'template_redirect', function() { $status = session_status(); if ( PHP_SESSION_DISABLED === $status ) ...
237,025
<p>We need to style a single page differently depending on what user journey you take. Currently we have event posts listed in WP, they are either under the "get involved > events" page or "urban innovation center > attend an event" some events are listed in both. If you come from "get involved > events" we need the si...
[ { "answer_id": 237034, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>There is no regular output and hence no header sent before <code>template_redirect</code> on the front end. If you nee...
2016/08/24
[ "https://wordpress.stackexchange.com/questions/237025", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101582/" ]
We need to style a single page differently depending on what user journey you take. Currently we have event posts listed in WP, they are either under the "get involved > events" page or "urban innovation center > attend an event" some events are listed in both. If you come from "get involved > events" we need the singl...
There is no regular output and hence no header sent before `template_redirect` on the front end. If you need sessions on the back end too, use the action `wp_loaded` to cover both. Example: ``` add_action( 'template_redirect', function() { $status = session_status(); if ( PHP_SESSION_DISABLED === $status ) ...
237,032
<p>I'm iterating over a custom post type that uses an image from the media library for each item. The images are being rendered for each one correctly with the right size, but for some reason it is loading the full image instead of the medium, which is greatly affecting my page load time.</p> <p>Here is what I have:</...
[ { "answer_id": 237034, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>There is no regular output and hence no header sent before <code>template_redirect</code> on the front end. If you nee...
2016/08/24
[ "https://wordpress.stackexchange.com/questions/237032", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93811/" ]
I'm iterating over a custom post type that uses an image from the media library for each item. The images are being rendered for each one correctly with the right size, but for some reason it is loading the full image instead of the medium, which is greatly affecting my page load time. Here is what I have: ``` ...
There is no regular output and hence no header sent before `template_redirect` on the front end. If you need sessions on the back end too, use the action `wp_loaded` to cover both. Example: ``` add_action( 'template_redirect', function() { $status = session_status(); if ( PHP_SESSION_DISABLED === $status ) ...
237,044
<p>According to the <a href="https://developer.wordpress.org/reference/functions/wp_get_nav_menu_items/" rel="noreferrer">docs</a>, <code>wp_get_nav_menu_items()</code> parameter 1 accepts</p> <pre><code>(string) (Required) Menu name, ID, or slug. </code></pre> <p>Here is how I'm registering my menus</p> <pre><code>...
[ { "answer_id": 237107, "author": "Ignat B.", "author_id": 38121, "author_profile": "https://wordpress.stackexchange.com/users/38121", "pm_score": 0, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code> $menu_name = 'primary'; \n\n if ( ( $locations = get_nav_menu_locations()...
2016/08/24
[ "https://wordpress.stackexchange.com/questions/237044", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44937/" ]
According to the [docs](https://developer.wordpress.org/reference/functions/wp_get_nav_menu_items/), `wp_get_nav_menu_items()` parameter 1 accepts ``` (string) (Required) Menu name, ID, or slug. ``` Here is how I'm registering my menus ``` register_nav_menus( array( 'primary' => 'Navigation primaire', ...
Since nobody has really explained why the function doesn't work the way you thought it did, I shall take a stab at explaining it in detail as I just fell for the same trap as you did. This is where the docs aren't really clear as to what the slug is referring to. Most people would assume its the slug of the registered...
237,081
<p>I have a variable that picks up data from the theme settings like background image and such, and it's stored in a separate file with inline <code>style</code> like:</p> <pre><code>$style = 'style="'.$background_image.$background_color.'"'; </code></pre> <p>The <code>$background_image</code> and <code>$background_c...
[ { "answer_id": 237050, "author": "Ivan Miranda", "author_id": 101610, "author_profile": "https://wordpress.stackexchange.com/users/101610", "pm_score": -1, "selected": false, "text": "<p>Paste your WordPress Address (URL) and your Site Address (URL). Plus give where you installed WP (may...
2016/08/25
[ "https://wordpress.stackexchange.com/questions/237081", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58895/" ]
I have a variable that picks up data from the theme settings like background image and such, and it's stored in a separate file with inline `style` like: ``` $style = 'style="'.$background_image.$background_color.'"'; ``` The `$background_image` and `$background_color` are just css values for `background_image` and ...
I'm not able to visit either link successfully. I get a redirect loop error: > > ERR\_TOO\_MANY\_REDIRECTS > > > Changing the URL of your website in *Settings > General > Site URL* is not enough unfortunately. You will still have your post content with your sub domain URL (`clasificados.example.com`) causing your...
237,086
<p>Is there a way I could show only the comments by a particular user role to his same user role?</p> <p>For example: The logged in user belongs to the "Advertisers" user role, he should only see the comments made by him and all users under his role.</p> <p>Thank you.</p>
[ { "answer_id": 237098, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 0, "selected": false, "text": "<p>Here's one way (untested) to display comments from users in the same role as the current user:</p>\n\n<pre><c...
2016/08/25
[ "https://wordpress.stackexchange.com/questions/237086", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101629/" ]
Is there a way I could show only the comments by a particular user role to his same user role? For example: The logged in user belongs to the "Advertisers" user role, he should only see the comments made by him and all users under his role. Thank you.
Yes you can, **Frontend only** you would need to check each post comment author for it's role. If the role of that comment author is not *adverstisers* then remove it from the array of comments attached to that post. Then you would have to return only the comments if the current logged in user is also from the *adv...
237,100
<p>For example, I have an url:</p> <pre><code>mysite.com/author/admin </code></pre> <p>It's not considered as single post or single page to add meta tag via SEO plugin. And to this page I want to add something like:</p> <pre><code>&lt;meta name="description" content="All posts by author admin."/&gt; </code></pre> <...
[ { "answer_id": 237113, "author": "teheteh", "author_id": 98699, "author_profile": "https://wordpress.stackexchange.com/users/98699", "pm_score": 0, "selected": false, "text": "<p>UPDT: Figured it out. Had to just hardcode it in header.php file located in my theme name folder.</p>\n\n<pre...
2016/08/25
[ "https://wordpress.stackexchange.com/questions/237100", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98699/" ]
For example, I have an url: ``` mysite.com/author/admin ``` It's not considered as single post or single page to add meta tag via SEO plugin. And to this page I want to add something like: ``` <meta name="description" content="All posts by author admin."/> ``` Is there are any way to do this? Thanks in advance!
There is not a standerized way to add HTML meta tags in WordPress but you can use [`wp_head` action](https://developer.wordpress.org/reference/hooks/wp_head/) as a generic way to add meta tags. I think description meta tag should not be in the theme, as you suggest in your answer, because description meta tag is a pro...
237,118
<p>I've been trying to find an explanation of the following code which I'm using to add pagination to a custom category template.</p> <pre><code>$catpage = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; $catnum = 3; $offset = ($catnum * $catpage) - 3; </code></pre> <p>In particular, ...
[ { "answer_id": 237121, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>The following code line:</p>\n\n<pre><code>$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;\n...
2016/08/25
[ "https://wordpress.stackexchange.com/questions/237118", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68414/" ]
I've been trying to find an explanation of the following code which I'm using to add pagination to a custom category template. ``` $catpage = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; $catnum = 3; $offset = ($catnum * $catpage) - 3; ``` In particular, I would like to know what ...
The following code line: ``` $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; ``` is using the [*ternary operator*](http://php.net/manual/en/language.operators.comparison.php) `?:` It's a shorthand notation for ``` if( get_query_var( 'paged' ) ) $paged = get_query_var('paged' ); else $page...
237,131
<p>This wonderful answer to a related question; that of displaying dimensions in the media library. </p> <p><a href="https://wordpress.stackexchange.com/questions/30894/display-image-size-in-media-library-screen">display image size in media library screen</a></p> <p>is it possible to use this technique to display the...
[ { "answer_id": 237138, "author": "Ethan O'Sullivan", "author_id": 98212, "author_profile": "https://wordpress.stackexchange.com/users/98212", "pm_score": 4, "selected": true, "text": "<p>In your theme's <code>functions.php</code> add the following code to get the file size for all of you...
2016/08/25
[ "https://wordpress.stackexchange.com/questions/237131", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57686/" ]
This wonderful answer to a related question; that of displaying dimensions in the media library. [display image size in media library screen](https://wordpress.stackexchange.com/questions/30894/display-image-size-in-media-library-screen) is it possible to use this technique to display the file size as a column? If s...
In your theme's `functions.php` add the following code to get the file size for all of your items in the *Media* library: ``` add_filter( 'manage_upload_columns', 'wpse_237131_add_column_file_size' ); add_action( 'manage_media_custom_column', 'wpse_237131_column_file_size', 10, 2 ); function wpse_237131_add_column_fi...
237,149
<p>I know that according default Wordpress boot process, firstly <code>functions.php</code> is called, after that goes all theme stuff. But I am currently going to refactor my theme completely to optimize it. My idea is to have one base css file for common properties, normalize, colors. Or to keep single css file, bu...
[ { "answer_id": 237153, "author": "bynicolas", "author_id": 99217, "author_profile": "https://wordpress.stackexchange.com/users/99217", "pm_score": 5, "selected": true, "text": "<p>It all depends on the scale of your customizations and how you will organize your stuff. But there is 2 mai...
2016/08/25
[ "https://wordpress.stackexchange.com/questions/237149", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93387/" ]
I know that according default Wordpress boot process, firstly `functions.php` is called, after that goes all theme stuff. But I am currently going to refactor my theme completely to optimize it. My idea is to have one base css file for common properties, normalize, colors. Or to keep single css file, but in this case...
It all depends on the scale of your customizations and how you will organize your stuff. But there is 2 main ways of doing it. ***functions.php*** and ***template files*** The way I like to do it, is **register** all my script/styles in functions.php so I know what I will work with but I will **enqueue** only what I n...
237,195
<p>bbPress has an annoying error about <code>bbp_setup_current_user was called incorrectly.</code> <a href="https://bbpress.org/forums/topic/bbp_setup_current_user-was-called-incorrectly/" rel="noreferrer">bbPress topic</a> and <a href="https://bbpress.trac.wordpress.org/ticket/2412" rel="noreferrer">bbPress ticket #24...
[ { "answer_id": 271698, "author": "sMyles", "author_id": 51201, "author_profile": "https://wordpress.stackexchange.com/users/51201", "pm_score": 2, "selected": false, "text": "<p>\"Technically\" it's just a PHP warning and not an error, and you should not have warnings enabled on producti...
2016/08/26
[ "https://wordpress.stackexchange.com/questions/237195", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58895/" ]
bbPress has an annoying error about `bbp_setup_current_user was called incorrectly.` [bbPress topic](https://bbpress.org/forums/topic/bbp_setup_current_user-was-called-incorrectly/) and [bbPress ticket #2412](https://bbpress.trac.wordpress.org/ticket/2412), and it looks like nothing will change to fix it. On the site...
"Technically" it's just a PHP warning and not an error, and you should not have warnings enabled on production servers. You can disable PHP from logging warnings and it will still log errors to the error log file. You can disable PHP warnings by setting it in a custom php.ini file on the server (all errors except for ...
237,211
<p>I seem to have a problem trying to display the "alternative text" of the featured image.</p> <p>Here is the code that I have been working on. Not sure why the alternative text is showing blank. </p> <pre><code> &lt;?php $projects = new WP_Query( array( 'post_type' =&gt; 'print-billboard' ) ); ...
[ { "answer_id": 237213, "author": "Rishabh", "author_id": 81621, "author_profile": "https://wordpress.stackexchange.com/users/81621", "pm_score": 0, "selected": false, "text": "<pre><code> if ( $projects-&gt;have_posts() ) : while ( $projects-&gt;have_posts() ) :\n $projects-&gt;the_po...
2016/08/26
[ "https://wordpress.stackexchange.com/questions/237211", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35356/" ]
I seem to have a problem trying to display the "alternative text" of the featured image. Here is the code that I have been working on. Not sure why the alternative text is showing blank. ``` <?php $projects = new WP_Query( array( 'post_type' => 'print-billboard' ) ); if ( $projects->have_po...
I am not so sure of what I am going to say, but from a fast look, $featured\_image is an array **(URL, width, height, is\_intermediate)**. so assuming that your alternative text exists in this array, you need to specify its index like this: **$featured\_image[index\_of\_alt\_text]** according to my understanding, the ...
237,212
<p><strong>What I am trying to do</strong></p> <p>I am adding a custom field to a WooCommerce email template, however I am trying to make the custom field only appear in one custom email template instead of all of them however i am struggling to achieve this. The template is called: <code>customer-completed-order.php<...
[ { "answer_id": 237213, "author": "Rishabh", "author_id": 81621, "author_profile": "https://wordpress.stackexchange.com/users/81621", "pm_score": 0, "selected": false, "text": "<pre><code> if ( $projects-&gt;have_posts() ) : while ( $projects-&gt;have_posts() ) :\n $projects-&gt;the_po...
2016/08/26
[ "https://wordpress.stackexchange.com/questions/237212", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101645/" ]
**What I am trying to do** I am adding a custom field to a WooCommerce email template, however I am trying to make the custom field only appear in one custom email template instead of all of them however i am struggling to achieve this. The template is called: `customer-completed-order.php` **What I have so far** Us...
I am not so sure of what I am going to say, but from a fast look, $featured\_image is an array **(URL, width, height, is\_intermediate)**. so assuming that your alternative text exists in this array, you need to specify its index like this: **$featured\_image[index\_of\_alt\_text]** according to my understanding, the ...
237,253
<p>I'm working on a project on my desktop for a theme development, but an issue I am having is that when the user clicks on the navigation menu, it causes it to collapse. Since I got collapse to work on hover, I don't need it when clicked.</p> <p>I'm using the theme Unite. I don't have a way of sharing this project, a...
[ { "answer_id": 237772, "author": "shamim khan", "author_id": 98304, "author_profile": "https://wordpress.stackexchange.com/users/98304", "pm_score": 1, "selected": true, "text": "<p>I think this will work for you\n<a href=\"http://jsfiddle.net/2Smgv/3100/\" rel=\"nofollow\">demo</a></p>\...
2016/08/26
[ "https://wordpress.stackexchange.com/questions/237253", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98508/" ]
I'm working on a project on my desktop for a theme development, but an issue I am having is that when the user clicks on the navigation menu, it causes it to collapse. Since I got collapse to work on hover, I don't need it when clicked. I'm using the theme Unite. I don't have a way of sharing this project, and only ha...
I think this will work for you [demo](http://jsfiddle.net/2Smgv/3100/) here is another js solution [demo2](https://jsfiddle.net/PRkonsult/mn31qf0p/1/) ``` $('ul.nav li.dropdown').hover(function() { $(this).find('.dropdown-menu').stop(true, true).delay(200).fadeIn(500); }, function() { $(this).find('.dropdown-men...
237,262
<p>I know how to display my field groups on specific pages (display location: page is equal to myPage). </p> <p>I have a few different templates on my site and would like to display Field Group X when the page is using template Y. Is this possible?</p>
[ { "answer_id": 237264, "author": "Ethan O'Sullivan", "author_id": 98212, "author_profile": "https://wordpress.stackexchange.com/users/98212", "pm_score": 3, "selected": true, "text": "<p>Hard to give an exact answer without sharing your code, but using <a href=\"https://developer.wordpre...
2016/08/26
[ "https://wordpress.stackexchange.com/questions/237262", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101727/" ]
I know how to display my field groups on specific pages (display location: page is equal to myPage). I have a few different templates on my site and would like to display Field Group X when the page is using template Y. Is this possible?
Hard to give an exact answer without sharing your code, but using [`is_page_template()`](https://developer.wordpress.org/reference/functions/is_page_template/) in an `if` statement will help determine when you display your custom field group: ``` if ( is_page_template( 'template-y.php' ) ) { # Display Field Group ...
237,266
<p>I want add a new settings box on the <em>Post</em> page. I'd like to be under the category or above, like so:</p> <p><a href="https://i.stack.imgur.com/ipng6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ipng6.png" alt="enter image description here"></a></p>
[ { "answer_id": 237268, "author": "bynicolas", "author_id": 99217, "author_profile": "https://wordpress.stackexchange.com/users/99217", "pm_score": 2, "selected": false, "text": "<p>You need to use the <a href=\"https://developer.wordpress.org/reference/functions/add_meta_box/\" rel=\"no...
2016/08/26
[ "https://wordpress.stackexchange.com/questions/237266", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101728/" ]
I want add a new settings box on the *Post* page. I'd like to be under the category or above, like so: [![enter image description here](https://i.stack.imgur.com/ipng6.png)](https://i.stack.imgur.com/ipng6.png)
You need to use the [`add_meta_box`](https://developer.wordpress.org/reference/functions/add_meta_box/) function ``` add_action( 'add_meta_boxes', 'my_custom_meta_box' ) ); function my_custom_meta_box(){ $args = array(); add_meta_box( 'my_metabox_id', __( 'My Meta Box', 'my_textdomain' ), // Title 'm...
237,270
<p>I have a taxonomy "artist" for two different custom post types ("project" and "product").</p> <p>I need to display a list of "artists", but only if they have related "products", and only if those products are still in stock.</p> <pre><code>$artists = get_terms( array( 'taxonomy' =&gt; 'artist', 'hide_empty' ...
[ { "answer_id": 237268, "author": "bynicolas", "author_id": 99217, "author_profile": "https://wordpress.stackexchange.com/users/99217", "pm_score": 2, "selected": false, "text": "<p>You need to use the <a href=\"https://developer.wordpress.org/reference/functions/add_meta_box/\" rel=\"no...
2016/08/26
[ "https://wordpress.stackexchange.com/questions/237270", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82/" ]
I have a taxonomy "artist" for two different custom post types ("project" and "product"). I need to display a list of "artists", but only if they have related "products", and only if those products are still in stock. ``` $artists = get_terms( array( 'taxonomy' => 'artist', 'hide_empty' => 1, ) ); ``` This in...
You need to use the [`add_meta_box`](https://developer.wordpress.org/reference/functions/add_meta_box/) function ``` add_action( 'add_meta_boxes', 'my_custom_meta_box' ) ); function my_custom_meta_box(){ $args = array(); add_meta_box( 'my_metabox_id', __( 'My Meta Box', 'my_textdomain' ), // Title 'm...
237,299
<p>I'm working in a blog with a template of my own. When I link to a category page (i.e. <code>mydomain.com/category/mycategory</code>) Wordpress generates this HTML code just after the <code>header.php</code>:</p> <pre><code>&lt;!-- HTML rendered by header.php --&gt; &lt;!-- This 2 lines belong to index.php --&gt; &...
[ { "answer_id": 237314, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 1, "selected": false, "text": "<ol>\n<li>Create another file form <code>header.php</code> and name it like <code>header-{category-name}.php<...
2016/08/27
[ "https://wordpress.stackexchange.com/questions/237299", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100952/" ]
I'm working in a blog with a template of my own. When I link to a category page (i.e. `mydomain.com/category/mycategory`) Wordpress generates this HTML code just after the `header.php`: ``` <!-- HTML rendered by header.php --> <!-- This 2 lines belong to index.php --> <div id="primary" class="content-area"> <main i...
Review the [template hierarchy](https://developer.wordpress.org/themes/basics/template-hierarchy/#category) from the Codex to gain a better understanding of what files are read when. This will help you to understand what's called in what situation (tag/category/front-page/etc). Content.php is never mentioned in the d...
237,301
<p>I'm trying to count the total number of paragraphs within each blog post but it is not getting executed and hence returning nothing. </p> <p><strong>How do you want to use this code?</strong></p> <p>Currently in my <code>function.php</code> I have the following code that I use to show up ads inside my post:</p> <...
[ { "answer_id": 237310, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 0, "selected": false, "text": "<p>If you just dump a <a href=\"http://php.net/manual/en/language.oop5.magic.php\" rel=\"nofollow\">magic function<...
2016/08/27
[ "https://wordpress.stackexchange.com/questions/237301", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50584/" ]
I'm trying to count the total number of paragraphs within each blog post but it is not getting executed and hence returning nothing. **How do you want to use this code?** Currently in my `function.php` I have the following code that I use to show up ads inside my post: ``` add_filter( 'the_content', '_some_func' );...
I'm pretty sure that `is_singular()` is going to return false when you are inside the WP loop, since there are more than one posts being looped through. Try `is_single()` or just look at the post object and examine the `post_type` attribute. ``` add_filter( 'the_content', '_some_func', 15 ); function _some_func( $con...