question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I am writing a widget who's form elements have a click event attached to. I bind it using jQuery. However, after clicking <code> save </code> , the bindings gets lost. That is, clicking those elements doesn't trigger the function anymore. I tried using the <code> on() </code> jQuery method, as suggested stackexchange-u...
Because the input box is getting rebuilt (or the entire form), I followed advice given me elsewhere, and instead of binding on() to an input box, I bind it higher up and use event delegation: <code> jQuery('#widgets-right').on('click','.icon_buttons input',function(){ openPanel(jQuery(this),jQuery(this).index()); }); <...
How do I rebind event after widget save
wordpress
I strongly need to edit some parts of the comments left by the users, I want to add a link to the commenter's author.php page if he/she is a registered user by placing a text link somewhere next to his/her name. I've this code <code> &lt;?php wp_list_comments(); ?&gt; </code> but I wonder if it's possible to have the f...
This function replaces the comment author's link with the comment author's profile page, if the comment author is a registered user. Otherwise, the standard WordPress comment author link is displayed. This function is not mine and has been found googling . <code> function graphene_comment_author_profile_link(){ /* Get ...
is it possible to have the full code instead in the comments.php page
wordpress
I have a custom post type called <code> Employees </code> where an employee's name is the <code> post_title </code> of each post. I am trying to figure out how I would sort the <code> post_title </code> column by last name. So for instance, if we have the following post entries: <code> 1. Justin Bieber 2. Selena Gomez ...
You could use <code> usort() </code> . Your callback function would need to determine the last names and sort by them. So, for instance: <code> $args = array( 'post_type' = 'Employees', ); $employees = get_posts( $args ); usort( $employees, 'wp91501_sort_employees' ); </code> and then your callback might be: <code> fun...
Specify strict 'order by' in WordPress query
wordpress
I have a CPT that I want to list the post in the frontend of my website, so i've created a page that I assigned a template so i'll be able to modify the way it look. Here is my template declaration : <code> /* Template Name: Book's author */ </code> Further I have my loop. In my wp-admin under page i've changed the tem...
What you are doing, if I understand correctly, is overly complicated, is a bit of a hack around the Core functionality of CPTs, and is probably less efficient than letting the Core handle it. WordPress will generate an index listing for your post type if you register it appropriately. That is, if you register it with <...
My template won't apply, theme still fallback to index.php
wordpress
Embarrassingly big hole in my understanding! When I've finished editing a post and click the big blue "Update" button, what happens next? In particular, how does the 'pre-post-update' hook (which, being php, exists only on the server) manage to intercept my request? I imagine that either there's something clever going ...
Yes, the page reloads. The form data is sent as a <code> POST </code> request to the server for processing. Whatever your jQuery script does needs to be reflected in some sort of input field(s) so that data can be passed to the server and intercepted by your <code> save_post </code> action.
How do wordpress hooks respond to user interaction?
wordpress
So my boss wants me to edit the backend of his WP site so that he can add a video link from a site called vzaar, which hosts all of our content. I need to know where in the backend I can edit to allow this to happen. I dont need to know how to do it, just need to know what I'm looking for. Here is an image of where he ...
It's Post Meta Box / Custom Field. Try find it in functions files inside the THEME folder.
Editing the Backend Uploader
wordpress
I have the code below in my functions.php file, it works great and allows me to use page templates in my custom post type 'services'. I have defined which 'type' to use on the first line with 'services'. <code> define('MY_CUSTOM_POST_TYPE', 'services'); </code> The problem is I have multiple custom post types. I want t...
Dump the constant <code> MY_CUSTOM_POST_TYPE </code> use the <code> $post-&gt;post_type </code> instead. <code> /** * Register the meta box */ add_action('add_meta_boxes', 'page_templates_dropdown_metabox'); function page_templates_dropdown_metabox(){ global $post; add_meta_box( $post-&gt;post_type.'-page-template', __...
Page Templates - this code only works for one Custom Post Type
wordpress
I have a site with urls like so: <code> site.com/folder/page-name </code> It is moving to another site built in wordpress and I am trying to recreate the page to ensure incoming links continue to work as normal. The posts are organised into different custom post types, but essentially they will display from the same pa...
When you add a custom post type, WordPress doesn't know that it needs to regenerate it's permalinks/rewrite rules. Visit the permalinks settings page to flush and regenerate the links and your custom post type permalinks will start to work, else you'll get 404 messages. A word of warning: Some people will advise you ca...
How to bypass 404 for certain pages/posts?
wordpress
I have this in my functions.php <code> function remove_quick_edit( $actions ) { unset($actions['inline hide-if-no-js']); return $actions; } add_filter('post_row_actions','remove_quick_edit',10,1); </code> to remove the quick edit link in the backend when scrolling the list of published posts. It works like a charm but ...
Use <code> current_user_can </code> to wrap the <code> add_filter </code> call: <code> if ( current_user_can('manage_options') ) { } else { add_filter('post_row_actions','remove_quick_edit',10,1); } </code> <code> manage_options </code> is an Admin capability. If the current user can do it, he's an admin (on a vanilla ...
Disable "quick edit" only for non admin in functions.php
wordpress
I need to change the values and hide some of the default media manager Attachment Display settings. Like setting the "Link to" to none, and hiding it so that the registered user can't change it. It would also be nice if I could delete the "size" option "original size from the dropdown. I googled a bit and it seems to b...
I got the solution. I used the following script: stackexchange-url ("Wordpress Media Manager 3.5 - default link to") and altered it to my needs with this modification: <code> (function() { var _AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay; wp.media.view.Settings.AttachmentDisplay = _AttachmentDisplay.ex...
Media Manager 3.5 custom options
wordpress
I want to modify search results. Currently I hook to the_posts and check wp_query-> is_search to determine if I am looking at the search results page. However, I noticed that the_posts is executed not only on the search results, but also on any excerpt list on the page (such as a listing of news items in the footer of ...
I'd say it's perfectly fine to do it the way you're doing it now, that is <code> function my_the_posts($posts, $query = false) { if( is_search() ){ // do your thing here } return $posts; } add_filter( 'the_posts', 'my_the_posts' ); </code> Don't worry about those excerpts in the footer, even though they may be part of ...
the_posts hook, which set of posts?
wordpress
I'm trying to use Query Multiple Taxonomies with Ajax. It works with Ajax and it works without it. But unfortunately not at the same time. Basically I need an Archive page to show only the posts of my custom post type "filme" (to insert it with ajax) and another Archive page with the menue, header etc. to use it with t...
Finally I found a solution. Maybe it could help someone else. In my archive-filme.php I just used the basic loop: <code> &lt;?php if ( have_posts() ) : ?&gt; &lt;?php while ( have_posts() ) : the_post(); get_template_part( 'content', get_post_format() ); endwhile; ?&gt; &lt;?php else : ?&gt; &lt;?php get_template_part(...
Two different archive pages showing the same content
wordpress
I figured out I can filter posts by format just by doing /type/{format} e.g. /type/gallery/ in the url. Looking for a way to filter by categories on top of this, something like /type/gallery/category/installation or /type/gallery/art. I've figured out the query, but I don't know how to handle the url bit: <code> $galle...
I ended up with this: <code> function when_rewrite_rules( $wp_rewrite ) { $newrules = array(); $new_rules['type/([^/]+)/category/([^/]+)/?$'] = 'index.php?post_format=$matches[1]&amp;category_name=$matches[2]'; $wp_rewrite-&gt;rules = $new_rules + $wp_rewrite-&gt;rules; } add_filter('generate_rewrite_rules','when_rewri...
How to filter posts by format and category via url?
wordpress
When a user clicks on the table row, I want to: save a value in the user profile go to a page I am within this loop: <code> &lt;?php $query = new WP_Query(array('post_type' =&gt; 'aanvraag', 'posts_per_page' =&gt;'-1', 'post_status' =&gt; array('publish', 'pending', 'draft', 'private'/* , 'trash' */) ) ); ?&gt; &lt;?ph...
In simple terms, window.location.href is javascript, and will run in the browser, but PHP runs on the server. In order to execute <code> update_usermeta() </code> you need to open a page with that block of code on it. The best way to do this from a click is to use AJAX (javascript) to visit the URL on which you have th...
Execute PHP code in Javascript onclick
wordpress
Been searching a lot for how to call a function in header.php where the function is in functions.php. How do I solve this? I have my function in functions.php like this: <code> function testFunction() { echo "This is a test"; } </code>
Simple! just call it <code> testFunction(); </code> wherever you want between php tags. But not a wp question
Calling a function from functions.php in header
wordpress
Is it possible to add the id or slug of a category in the output of wp_nav_menu menu's? For example, the standard output of wp_nav_menu is: <code> &lt;div class="menu-header"&gt; &lt;ul id="menu-categorieen" class="menu"&gt; &lt;li id="menu-item-4353" class="menu-item menu-item-type-custom menu-item-object-custom curre...
Use the <code> nav_menu_css_class </code> filter to add classes to <code> wp_nav_menu </code> output. Add ID (no additional query needed): <code> function wpa_category_nav_class( $classes, $item ){ if( 'category' == $item-&gt;object ){ $classes[] = 'menu-category-' . $item-&gt;object_id; } return $classes; } add_filter...
Adding category ID or slug to WP Nav Menu
wordpress
I list my two most recent posts from a widget on the sidebar. When I'm viewing one of these posts from single.php, I want that post to be excluded from the list and instead show the next post in order. single.php looks something like this: <code> &lt;?php if ( have_posts() ) : ?&gt; &lt;?php while ( have_posts() ) : th...
The post__not_in arg should work for you: <code> $args = array( 'numberposts' =&gt; 5, 'offset' =&gt; 0, 'category' =&gt; 7, 'post__not_in' =&gt; array( $post-&gt;ID ) ); $myposts2 = get_posts($args); </code>
How do I exclude the current post from listing in recent posts
wordpress
Before installing a big plugin I'm always scared of the blank page so I usually add define('WP_MEMORY_LIMIT', '64M'); to wp-config.php beforehand. I was thinking I could add it immediately after any WordPress install. Does this have potential downside?
The short answer is no. The long answer is "it is complicated". The memory limit is there to protect you from malfunctioning code eating all your available memory, something that will make your site less responsive for a while. (I tried to explain the issues around this setting here ) This setting will not matter if yo...
Adding define('WP_MEMORY_LIMIT', '64M'); by default?
wordpress
I am writing a plugin that enables subscribed users to submit posts of a custom type, and I am trying to implement this feature via shortcodes. Now the problem is that instead of inserting one post, my code inserts hundreds of them, until PHP runs out of memory... Here is an ultraminimal code that reproduces the issue:...
Ok, after digging for a while, I found the reason: the Relevanssi plugin expands every shortcode by default when building its index. For some reason, this caused the function referred to by my shortcode to be executed infinitely many times... Thus the solution is simply to edit the Relevanssi settings to tell it not to...
Yet another wp_insert_post infinite loop. What is wrong?
wordpress
Is it possible to implement a different stylesheet for a page using a url variable, for example Normal URL: www.example.com/page Would use the normal stylesheet Alternative URL: www.example.com/page?=alt Would use an alternative stylesheet
if the url is <code> www.example.com/page?style=alt </code> , you can conditionally check the presence of <code> $_GET['style'] </code> when you're including your styles. Add the following where you are enqueueing your syles(probably in <code> functions.php </code> ): <code> if(isset($_GET['style']) &amp;&amp; $_GET['s...
Using variable to display a page with a different stylesheet
wordpress
In my <code> &lt;title&gt; </code> tags I am getting <code> undefined </code> on a custom taxonomy in a custom post type and im struggling to find a way to set it. <code> &lt;title&gt;&lt;br /&gt; &lt;b&gt;Notice&lt;/b&gt;: Undefined property: stdClass::$labels in &lt;b&gt;/www/public_html/lib/wp-includes/general-templ...
I managed to fix this $labels undefined by writing the following work around. Its custom to how I wanted it to work but it may give others a pointer of how to get it to work for them. It occurs when Wordpress could use two types to serve its page and gets confused. Say if the page being served could be an archive page ...
stdClass::$labels /wp-includes/general-template.php undefined
wordpress
I would like to add my new developed plugin's admin menu to an existing plugin as sub menu. Would be possible to do this? In my first plugin I initilize the menus as follows: <code> function add_pages() { // Add a new top-level menu (ill-advised): add_menu_page(__('MyMenu','menu-test'), __('MyMenu','menu-test'), 'manag...
Trying to simulate the issue, it happened the same ( <code> wp-admin/submenu_slug </code> ), and the solution is to add a priority value in the hook <code> admin_menu </code> . Here, I'm adding a sub menu to the plugin BackWPup . Note the priority <code> 11 </code> : <code> add_action('admin_menu', 'third_party_submenu...
Admin menu as submenu from another plugin
wordpress
I just set up Wordpress Multisite on my local machine following this tutorial. When I try to login to the admin using Google Chrome, the page just refreshes. I've tried Firefox, and I'm able to login and use Wordpress Multisite normally and access the dashboard. I've tried clearing my cache, and using incognito mode in...
I solved my own problem. I installed WordPress MU Domain Mapping plugin, set the mapping my to home ip, 127.0.0.1, then added my site to domains with the domain name I wanted. The domain name in domains must match the site domain. Once all of that was done, I made sure the domain was also mapped in my hosts file. I hop...
Wordpress Multisite local: wp-login.php refreshes on login Chrome Browser
wordpress
I have a custom taxonomy called services. Each service term will have a description. I am using get_the_term_list to show all the terms attached to each post. When hovering over the term link in the front-end I would like to show the term description just like WordPress does within the back-end when you hover over any ...
If you mean to add the description of the term as a title attribute which will show on hover then you can "fork" <code> get_the_term_list </code> function to a version that would add the title attribute, something like this should work: <code> function get_terms_with_desc( $id = 0 , $taxonomy = 'post_tag', $before = ''...
Display term description on hover using get_the_term_list
wordpress
I would like to have to query loops running on my blog homepage: Featured posts on top displaying 3 posts from the category : "Featured" Underneath it just the basic loop of wordpress which display the latest (10 or other, whatever is selected within the admin) with "next" and "previous" buttons for archive posts (page...
You can use this code to get 3 posts from category Featured <code> $args = array( 'category_name' =&gt; 'featured', 'posts_per_page' =&gt; 3 ); $featured_posts = new WP_Query( $args ); if ( $featured_posts-&gt;have_posts() ): while ( $featured_posts-&gt;have_posts() ): $featured_posts-&gt;the_post(); // Here you can us...
2 loops in blog homepage
wordpress
I'm getting this error with my custom post metabox. The custom post and metabox works fine, but if i have debug on and when i try to save any other page or post, i will get an error: Notice: Undefined index: at_nonce in /Users/jay/site/wp-content/themes/mytheme/dogs-post-type.php on line 53 Notice: Undefined index: at_...
These are your problem lines: <code> if ( $_POST &amp;&amp; !wp_verify_nonce($_POST['at_nonce'], __FILE__) ) { return; } </code> You check to see that <code> $_POST </code> is set, but you don't check <code> $_POST['at_nonce'] </code> . If <code> $_POST </code> is set but that key is not then you will get a <code> Noti...
Undefined index: at_nonce in custom post metabox
wordpress
I'm using the following as part of a shortcode I'm creating: <code> $loop = new WP_Query(array('post_type' =&gt; 'client', 'posts_per_page' =&gt; $limit, 'orderby' =&gt; $orderby)); if($loop){ $preoutput = '&lt;div class="outer"&gt;'; $postoutput = '&lt;/div&gt;'; while ($loop-&gt;have_posts()){ $loop-&gt;the_post(); $...
You are using <code> the_post_thumbnail </code> , which directly outputs the thumbnail in an image tag. You need to use <code> get_the_post_thumbnail </code> instead, which returns the image.
Post thumbnail not displaying in correct position
wordpress
I have a client who want's to be given admin access to the dashboard of the test installation of her website on my server. She hasn't paid me yet so I don't want her to be able to go into the themes menu, copy the theme code and run off without paying. So, is there a way that I can give her admin access while also bloc...
I would just disable the editor entirely . It is a dangerous tool anyway. I compare it to working on an airplane while its flying. Edit <code> wp-config.php </code> to add: <code> define('DISALLOW_FILE_EDIT',true); </code> You can reverse that by re-editing your <code> wp-config.php </code> and uploading over FTP (or m...
Restrict access to certain dashboard pages based on user id
wordpress
I am using an events plugin and struggling to get my database query to be perfect. The query is on the event-single.php template. What I need the query to do: Query the "events" custom post type for upcoming events Sort by <code> _event_start_date </code> meta_key to show earliest date (nearest event) Not display PAST ...
You're pretty close, but I wouldn't be distracted by the 'scope' meta key. The following is untested. <code> &lt;?php $args = array( 'post__not_in' =&gt; array($donotrepeat), "post_type" =&gt; 'event', 'meta_key' =&gt; '_event_start_date', // name of custom field 'orderby' =&gt; 'meta_value', "order" =&gt; 'ASC', "post...
Upcoming Event: How do I sort database by custom date field, but ignore past dates?
wordpress
<code> function set_copyright_options() { delete_option('ptechsolcopy_notice'); delete_option('ptechsolcopy_reserved'); add_option('ptechsolcopy_notice','Copyright &amp;copy;'); add_option('ptechsolcopy_reserved','All Rights Reserved'); } register_activation_hook(__FILE__, 'set_copyright_options'); </code> Hi I use the...
You could make another function with will (re)set the default option values: <code> function wpse_91307_set_option_defaults() { $options = array( 'ptechsolcopy_notice' =&gt; 'Copyright &amp;copy;', 'ptechsolcopy_reserved' =&gt; 'All Rights Reserved' ); foreach ( $options as $option =&gt; $default_value ) { if ( ! get_o...
How to reset the plugins without deactivate the plugin
wordpress
I'd like to display all posts within a given price range. For example: When a user inputs 100 and 1000 (in two separate form fields) - my site will display all posts that have a custom field called price that has a numeric value between 100 and 1000. Found this under the documentation for WP Query; however, I'm unsure ...
Use the <code> pre_get_posts </code> action to detect some filter vars in the URL and filter the query accordingly. For example, say your form sets <code> price_low </code> and <code> price_high </code> GET vars, so the URL looks like: <code> domain.com/?price_low=100&amp;price_high=1000 </code> Then your filter functi...
Query Posts by Custom Field 'Price'
wordpress
I think I just coded myself into a corner. I am setting up a page with an image. The image is an imagemap with lots of links. When you click on the link, it opens a post in a colorbox. So far I have managed to get this part working using a combination of the Lightbox Plus and Post Template plugins. Unfortunately this i...
A potential solution would be to first get rid of the Post Template plugin and just use the default <code> single.php </code> to render single post views. Then add a get variable onto the end of your imagemap links, so they're something like <code> domain.com/post-name/?view=lightbox </code> Then filter the <code> sing...
Display one post in different formats conditionally
wordpress
How do I correctly get the data from a drop down (select) output into the Woocommerce Order Details section of the admin? When I do this, I get an output for all my text box questions, but nothing for the select (dropdown). <code> $this-&gt;address_formats = apply_filters('woocommerce_localisation_address_formats', arr...
Take a look at the WooCommerce docs here: Tutorial – Customising checkout fields using actions and filters your code would look something like this: <code> function my_custom_checkout_field( $checkout ) { woocommerce_form_field( 'my_field_name', array( 'type' =&gt; 'select', 'class' =&gt; array('my-field-class form-row...
Output dropdown results into Woocommerce Order details
wordpress
I'm following a course where the tutor uploads an image to his media library. He adds attachment information. He then creates a new post and includes the image. When he clicks through, he gets the image with his attachment info below it. I however do not. I click through and I just get the image by itself. I'm sorry, I...
It sounds like you have selected <code> Media file </code> instead of <code> Attachment Page </code> in the <code> Attachment Display Settings </code> :
Why can't I see my attachment page information for an image?
wordpress
I have a custom post type and used get_next_post() and get_previous_post() to create a simple pagination. However i need to create a pagination loop (if that is the correct term). If i'm on the first post i need to browse back to the last post and if i'm on the last post i need to browse to the first post. Is there a s...
Here is one idea for the previous post circle : <code> $next_post = get_next_post(); $prev_post = get_previous_post_circle(); </code> where we have defined this function: <code> function get_previous_post_circle($in_same_cat = false, $excluded_categories = ''){ $prev_post = get_previous_post($in_same_cat,$excluded_cate...
Pagination go to first page if i'm on last post
wordpress
I am including jQuery in my <code> header.php </code> file like this: <code> &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" &gt;&lt;/script&gt; </code> But when doing this, it breaks my home page slider, it breaks my google maps ultimate plugins and some other things. When I exclude it, no ...
You should not include jQuery manually. jQuery is included in WordPress by default, but isn't loaded on every page unless a plugin or theme requests it. This can be done using: <code> add_action('wp_enqueue_scripts','my_scripts'); function my_scripts() { wp_enqueue_script('jquery'); } </code> Here is function reference...
jQuery breaking my wordpress site
wordpress
I have form that i'm using to update user profile from front end and i have country select. <code> &lt;form method="post" id="adduser" action="&lt;?php the_permalink(); ?&gt;"&gt; &lt;select id="te" name="usercountry_id"&gt; &lt;option value="1"&gt;Country 1&lt;/option&gt; &lt;option value="2"&gt;Country 2&lt;/option&g...
Ok, i found what was the problem. I called $_POST in form itself instead of in form processing code. I was using default WordPress form processing code for user profile. <code> if ( 'POST' == $_SERVER['REQUEST_METHOD'] &amp;&amp; !empty( $_POST['action'] ) &amp;&amp; $_POST['action'] == 'update-user' ) { if ( !empty( $...
Get selected value with PHP and jQuery
wordpress
My problem is that i don't know how to set up a echo I think. I need it to just wrap a if statement correctly around the code below Please Help...Thanks SO much <code> &lt;?php global $post; if(get_post_type($post-&gt;ID) == 'videos') { &lt;video class="video" width="&lt;?php echo get_field('width'); ?&gt;" height="&lt...
You can use get_post_type() function and pass current post id to it. <code> global $post; if(get_post_type($post-&gt;ID) == 'videos') { // do this } </code> Update <code> &lt;?php global $post; if(get_post_type($post-&gt;ID) == 'videos') { ?&gt; &lt;video class="video" width="&lt;?php echo get_field('width'); ?&gt;" he...
How to set up a echo?
wordpress
I want to replace below class with <code> active </code> class in menu: <code> .current-menu-item </code> and <code> .current_page_item </code> I am already using a menu callback which add a class <code> dropdown </code> in child menu: <code> class foundation_navigation extends Walker_Nav_Menu { function start_lvl(&amp...
Add this line at top of your display element function: <code> add_filter('nav_menu_css_class', 'add_active_class_to_nav_menu'); </code> Add this line at bottom of your display element function: <code> remove_filter('nav_menu_css_class', 'add_active_class_to_nav_menu'); </code> Add this function somewhere in your themes...
replace current_page_item class in menu
wordpress
I had covered basically all the pages listed in the Template Hierarchy: <code> 404_template archive_template author_template category_template tag_template taxonomy_template home_template front_page_template page_template search_template single_template attachment_template </code> I'm using the front-page.php for my st...
<code> index.php </code> is shown whenever wordpress doesn't find an appropriate page template. Generally people use it as the template for their site's blog. If you are absolutely sure that it will never be reached, you can leave it empty. Just make sure you have that file present, otherwise the theme will not work As...
What should I put on my index.php?
wordpress
I have the following custom post types: books, documents, examples, guidebooks, onlineaids. They were generated by the following code: <code> /*-----------------------------------------------------------------------------------*/ /* CPT - Books */ /*----------------------------------------------------------------------...
I believe you need a <code> tax_query </code> like the following from the Codex : <code> $args = array( 'post_type' =&gt; 'post', 'tax_query' =&gt; array( array( 'taxonomy' =&gt; 'people', 'field' =&gt; 'slug', 'terms' =&gt; 'bob' ) ) ); $query = new WP_Query( $args ); </code> In your case that would look something lik...
Order custom posts by taxonomy?
wordpress
I have wp e-commerce plugin installed and custom building custom global search My query looks like this <code> SELECT * FROM aka_v_posts LEFT JOIN aka_v_postmeta ON aka_v_posts.ID=aka_v_postmeta.post_id AND ((aka_v_postmeta.meta_key='_wpsc_special_price' AND aka_v_postmeta.meta_value &gt; '0') OR aka_v_postmeta.meta_ke...
Thank's everyone for your attention. If anybody will need to query database with two postmeta, here is the code <code> SELECT p.* , CASE WHEN m1.meta_value=0 OR m1.meta_value IS NULL THEN m2.meta_value ELSE m1.meta_value END meta_value FROM aka_v_posts p LEFT JOIN aka_v_postmeta m1 ON p.id=m1.post_id AND m1.meta_key='_...
Custom MySQL Query with logic
wordpress
I have my wordpress site in a root folder like this "www.mysite/myblog/" so to get to the blog you have to go to "www.mysite/myblog/" I'm wanting to make it so that a user can go to "www.mysite" and it hits the blog. What do I need to do. All my images and everything have the ".../myblog/" path. I don't want to have to...
Copy the index.php and .htaccess file(Just copy it , do not move it ) from myblog directory to root directory. Open index.php file in any text editor and find the following code in the file. <code> /** Loads the WordPress Environment and Template */ require('./wp-blog-header.php'); </code> Replace it with the following...
wordpress url correction
wordpress
I've created a custom post type called "teacher" and I want to use that person's display name as the title of their post. Details: 1. The "teacher" custom post type supports title. 2. Only logged in teachers can post. 3. I'm using frontend posting by Rev Voodoo I've come up with this based on various snippets I've foun...
If you are using that code by Rev Voodoo, you will need to edit that code, not try to hook into WordPress core code. The form in that link submits to itself, and handles its own post processing thus bypassing many core hooks. Some of the hooks you are trying to use aren't going to work. I won't swear to it without inve...
How to use the Display Name as the post title in a custom post type?
wordpress
I have this code which works in a file called downloads/download.php: <code> &lt;?php header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename="file.pdf"'); readfile('file.pdf'); ?&gt; </code> It correctly prompts to download file.pdf. I need to track downloads so I want to ma...
I think Wordpress is having problem with the url of your external script and throws a 404 error from the <code> handle_404() </code> function in the <code> wp </code> class in <code> /wp-includes/class-wp.php </code> You can try to overcome that using for example <code> status_header(200) </code> <code> &lt;?php define...
Force pdf download not working when include blog-header.php
wordpress
Not sure what to call this one, but I am working on a form that asks for product information (name, description, color, features, etc.) but what I'd like to do is give users the option to add additional products by clicking on a link. They could add as many products as they need. After they finish entering information ...
Instead of looking for a plugin I found a piece of code that solves my problem, unfortunately because I am not using a plugin this post doesn't relate to WordPress and is off-topic. For those of you who are curious the code I am using is at: http://charlie.griefer.com/blog/2009/09/17/jquery-dynamically-adding-form-elem...
Duplicating/Cloning Multiple Form Fields
wordpress
In my website I have three custom post types: scripts, scenes and plugins. When visiting the archive page of a single post type (i.e. by going to mysite.com/plugins) you correctly see all the posts of that type. In archive.php, how can I find out which custom post type the user is looking at right now? I tried the foll...
There are a several of ways to do this. Put: <code> var_dump($wp_query-&gt;query,get_queried_object()); die; </code> In your <code> archive.php </code> and you should see two of those ways. <code> $wp_query-&gt;query </code> will have <code> post_type </code> component for custom post types. That will not be there for ...
How to get the custom post type from an archive page?
wordpress
is it possible to use <code> add_filter </code> or something similar to add the <code> slug </code> of the category as classname to the <code> the_category() </code> function? Right now when using <code> the_category() </code> the output looks like this … <code> &lt;ul class="post-categories"&gt; &lt;li&gt; &lt;a href=...
First locate <code> the_category() </code> in the Codex . Scroll down to the bottom of the page to "Source Code". There is a link " <code> the_categfory() </code> is located in ...". Click the link, you will be redirected to the source code . Alternativly open the file <code> wp-includes/category-template.php </code> i...
Add classname to the_category() function?
wordpress
I have a custom post type for my videos. I need do related it with other post category. And i have 10 category Like this : <code> Post Category - Video Category Tech Tech Marketing Marketing News News ..................... </code> I want to do for this. I have a post Category Tech and I have custom post type Category(T...
From your question I gather your taxonomy term names match your category names. If this is the case and always will be the case, why not just query your custom post type by category slugs? Not sure what the exact name is, so I just made it <code> video </code> . <code> // get category slug $cat = get_category( get_quer...
Custom Post Types relationships
wordpress
WordPress 3.5.1 Web Host: Windows Azure Cloud Database Host: Cleardb Web Server: IIS 7.5 I've built a custom child theme that runs on the Genesis Framework and it has multiple custom post types and metaboxes. Multiple plugins installed on the site as well. Since yesterday my admin user can no longer perform the followi...
For anyone else running into a similar issue with Azure Cloud hosting and ClearDB ... read below (even though this is very specific to my site and db config): Fixed the issue. This was a database specific issue with Azure and ClearDB and not pointing to the correct database. I was using a free version of the ClearDB My...
Lost administrator privileges and can't find a fix
wordpress
I understand the following about functions.php: Unlike style.css, the functions.php of a child theme does not override its counterpart from the parent. Instead, it is loaded in addition to the parent’s functions.php. (Specifically, it is loaded right before the parent’s file.) The problem with this logic is that things...
The answer is to remove things in your child theme via an action that runs before the action the parent theme has hooked to, everything should be happening within an action of some sort. For example, in your parent theme: <code> function do_something(){ // something happens here } add_action( 'init', 'do_something' ); ...
Child themes, over riding in the parents theme
wordpress
I built a plugin, and I would like to use shortcodes in the integrated wp_editor. I'm using echo to display the content of the wp_editor, so I think that's the problem why I can't use the shortcode. What's the method to do that? I'm using the following code for shortcode: <code> add_shortcode('facebook', 'facebook'); f...
try doing this <code> &lt;?php $footer = get_option('footer_options'); $footer_content = array($footer['footer_content_1'], $footer['footer_content_2']); foreach($footer_content as $content) { $content = apply_filters('the_content', $content); echo'&lt;aside class="tab-content"&gt; '.$content.' &lt;/aside&gt;'; } ?&gt;...
wp_editor returns the shortcode and not render the output
wordpress
I am trying to have WordPress automatically save the "credit" metadata that is stored within images I am uploading. I know this would be entered as a custom post meta field using <code> update_post_meta() </code> . The "credit" information is gathered by <code> wp_read_image_metadata() </code> , but <code> media_handle...
You can use <code> wp_generate_attachment_metadata </code> : This function generates metadata for an image attachment. It also creates a thumbnail and other intermediate sizes of the image attachment based on the sizes defined on the Settings_Media_Screen. The second argument of the filter is the attachment ID, so it s...
Save camera info as metadata on image upload?
wordpress
I am using a RSS feeds widget on my dashboard as stackexchange-url ("shown in this Q&amp;A"). Problem is feeds doesn't show up any visual like images or videos. I verified this by looking raw feeds which I used. Here is a snapshot of my feed dashboard widget: . How can I get visuals or is this the way WordPress shows d...
I couldn't manage to make <code> wp_widget_rss_output </code> to show the content without stripping HTML tags. Reference Q&amp;A's: stackexchange-url ("WordPress SimplePie modifications") stackexchange-url ("Displaying images from external RSS feeds?") But, using the function <code> fetch_feed </code> we can grab the f...
RSS dashboard widget not showing visuals
wordpress
On my custom dashboard, I want to show the number of total new comments (somehow like "right now"). Just like "You have ... open comments to take care of". So all I want is the total number not a list for each post or so. But I can't get this right. Any help out there? In the meantime I got some info (from wpmudev) on ...
Actually, it is not that hard. The last access time for a user is in <code> get_user_meta( get_current_user_id(), 'last_access', TRUE ) </code> . The date of each comment is in the column <code> comment_date </code> . Both share the same format, so we can compare them in SQL with a simple <code> &gt; </code> . There is...
show number of open comments on custom dashboard
wordpress
I'm trying to build a custom search results page. The problem I'm running into is that when I enter a search term ; say 'gaming', it will only return one result, being the latest result. I have my blog setup to display only one article at a time. However, I found a way to circumvent the search results page by logging i...
Change <code> &lt;?php if (have_posts()) : ?&gt; &lt;?php while (have_posts()) : the_post(); ?&gt; </code> to <code> &lt;?php if ($allsearch-&gt;have_posts()) : ?&gt; &lt;?php while ($allsearch-&gt;have_posts()) : $allsearch-&gt;the_post(); ?&gt; </code> because otherwise you don't utilize your custom query. See WP_Que...
Custom Search Result Page displaying only 1 result.
wordpress
I am new to PHP, mySQL and scripting in general. I'm trying to design a WP custom post type which would be like a point on a timeline or an item on a resume. I'm having trouble designing the structure of the data in a nice, neat way. Each post or 'item' can be either dated or undated. If it's dated, it can either be an...
If I understood you right, you need only two meta fields: <code> start_date </code> and <code> end_date </code> for your posts. Then you can compare current date to these fields and create (update) a taxonomy for the posts: Undated, if the post have no both start and end dates; Dated, if there only start date exists an...
Designing a custom post type with a minimum number of meta fields
wordpress
I need to check if a file exist in my plugin dir: <code> if (fileexists) { ... } else { ... } </code> However, if in place of fileexists I use <code> file_exists(WP_PLUGIN_DIR . "/myplugin/myfile.ext") </code> it returns always true, whereas if I use <code> file_exists(plugins_url( "myfile.ext", __FILE__ )) </code> it ...
Use <code> if( file_exists(plugin_dir_path(__FILE__) . 'myfile.ext') ) {} </code> instead of <code> if( file_exists( plugins_url( "myfile.ext", __FILE__ ) ) ) {} </code> See plugin_dir_path in the Codex.
check if a file in a plugin folder exists from a locale installation
wordpress
<code> &lt;div class="single_post"&gt; &lt;?php // The Query query_posts( $args ); // The Loop if(have_posts()) : while ( have_posts() ) : the_post(); ?&gt; &lt;div class="left_date"&gt; &lt;h1&gt;&lt;?php the_time('d') ?&gt;&lt;/h1&gt; &lt;p&gt;&lt;?php the_time('M') ?&gt;&lt;/p&gt; &lt;span class="year"&gt;&lt;p&gt;&...
Just put them between endwhile; and endif;
Is that the query_posts() the real criminal here?
wordpress
I saw this Javascript feature tour file today, and was curious how I would go about implementing it on the homepage of a WordPress site. Ideally, I'd like to add it so it only shows up if and only if a user is on the homepage and have never been there before. I'm new to this though, and I'm not sure how to implement it...
You would enqueue it, this is how Javascript is added to WordPress properly. This function would typically go in your theme's <code> functions.php </code> or in a plugin. <code> function my_scripts_intro() { is_front_page(){ wp_enqueue_script( 'introjs','path to ..intro.js' ); wp_enqueue_style( 'introcss','path to ..in...
How to implement a JavaScript and CSS file for my WordPress homepage?
wordpress
I have already followed the tutorial here: http://www.rlmseo.com/blog/passing-get-query-string-parameters-in-wordpress-url/ But it still doesn't work. In the function.php, my code is <code> //decode wordpress url to jquery string function add_query_vars($aVars) { $aVars[] = "lastName"; return $aVars; } // hook add_quer...
The tutorial is outdated and it seems it missed to flush the rules. <code> function add_rewrite_rule_and_tag() { global $wp_rewrite; add_rewrite_rule( '^physician-profile/([^/]*)/?', 'physician-profile?lastName=$matches[1]', 'top' ); add_rewrite_tag( '%lastName%','([^&amp;]+)' ); if ( ! isset( $wp_rewrite-&gt;rules['^p...
Passing the JQuery string to Worldpress URL
wordpress
I recently asked a question about an error I was getting for doing theme updates where the user did not have permission. I would like to write a credential check, much like how wordpress does theirs. essentially when you update WordPress you either have the worlds most insecure set up and it will just update when you c...
simple function: <code> protected function _cred_check(){ $aisis_file_system_structure = WP_Filesystem(); if($aisis_file_system_structure == false){ echo '&lt;div class="alert"&gt;&lt;strog&gt;NOTE!&lt;/strong&gt; We need your ftp creds before we continue!&lt;/div&gt;'; return true; } return false; } </code> then do: <...
How to throw the "We need ftp info" at a user
wordpress
I need to be able to show some informations only to the author in his profile viewable in the front end, for istance I need to add a text under the avatar that only the author, if logged in, can see. This text will inform them that they can change the avatar anytime by adding it in their profile page... I could also ad...
This one works for me... <code> &lt;?php global $current_user;&lt;br&gt; get_currentuserinfo(); if (is_user_logged_in() &amp;&amp; (current_user_can('edit_others_posts') || $current_user-&gt;ID == $post-&gt;post_author) ) {my text goes here'); } ?&gt; </code>
Show infos only to the author in the author.php
wordpress
I'm interested to know how the download history of plugins is calculated on WordPress.org. I'm noticing that one of my plugins is displaying a small percentage of users using a version which I haven't released yet via WordPress.org. Is it because I have installed it manually on a couple of my sites for testing?
I've answered a similar Question: stackexchange-url ("Does the number of downloads displayed for a plug-in in the WordPress.org plug-in directory include automatic updates?") This is Otto's blog post in make.wordpress.org with plenty of information about this stats. Excerpts from the whole page (article and comments), ...
How is the WordPress.org plugin download history calculated?
wordpress
I would like to use <code> wp_save_image_editor_file </code> filter, but there is no documentation on the internet. Also, it seems that no matter how many arguments I pass to the handler, all are null.
The filter inside <code> ~/wp-admin/includes/image.edit.php </code> looks like this: <code> apply_filters('wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id); </code> So a callback would look like the following: <code> add_filter( 'wp_save_image_editor_file', 'wpse91038_saved_image_editor_file',...
How can I use wp_save_image_editor_file filter?
wordpress
I have a wordpress blog set up on my site, example "blog.domain1.com". I have several categories and write posts under each category. I have one specific category that I don't want google search to show on the results page and also the articles written under this category. I used robots.txt and added this Disallow: /ca...
Hook into the action <code> wp_head </code> , test if you are on the category archive or a single post with that category, and print the proper <code> meta </code> element : <code> add_action( 'wp_head', 'wpse_91073_noindex' ); function wpse_91073_noindex() { if ( ( is_singular() &amp;&amp; in_category( 'CATEGORY_SLUG'...
how to hide specific post from google search
wordpress
Is it possible to create a widget where it can make changes to the container? An example is like this: <code> &lt;!--- widget-container ---&gt; &lt;div class="wdget"&gt; &lt;div class="textwidget"&gt; &lt;!--TOPWIDGET--&gt; &lt;div style="clear:both;"&gt;&lt;/div&gt; &lt;!--- &lt;=== See this =---&gt; &lt;!--/TOPWIDGET...
I would not recommend that. Much easier to use a clearfix hack to force clearing and just add that style to your widget. Clearfix hacks are transparent: it doesn't matter if they happen on all elements there is no visible difference, other than clear floats. Somewhere in your themes <code> style.css </code> : <code> .w...
Widget where it can make changes to the container
wordpress
I'm opening my posts in an iframe, and I'm using get_the_category_list to list post's categories. The problem is that when a user clicks on the category link, it opens in the iframe. How can I set the target for these generated links to be "_parent"?
<code> get_the_category_list </code> runs it output through the filter <code> the_category </code> . You could hook in there and change whatever you like. Something like this should work (untested): <code> &lt;?php add_filter('the_category', 'wpse90955_the_category'); function wpse90955_the_category($cat_list) { return...
get_the_category_list open in parent window
wordpress
Will I lose the pages I've created within the default Wordpress theme when adding a new theme or will a new theme accommodate the same structure and content already created. I'm new to Wordpress and can't find the answer on Google.
WordPress is a content management system. Your content is saved in a database and is independent of whatever theme you choose to use to display that content. So, short answer: no.
Will I lose the pages I've created within a default Wordpress theme when adding a new theme?
wordpress
I want to validate a phone number and make sure the user enters all 10 digits. This can be done using the HTML5 pattern atribute: <code> &lt;input pattern=".{10,}" title="10 characters minimum"&gt; </code> How can I add this pattern attribute to my input tag in Contact Form 7 ? This what the mobile number input shortco...
You can use a <code> tel </code> shortcode to do this: <code> [tel* id:field-mobile 10/10 "placeholder text"] </code> This brings up the issue of browser support; if the browser in use does not support the <code> tel </code> input type, it will fall back to a plain text field. Source: http://contactform7.com/text-field...
Adding attributes to HTML tags in Contact Form 7
wordpress
When using the 'fields' => 'ids' parameter, is it better to create a new WP_Query in the code below rather than doing get_posts? How would the loop look if I used WP_Query? <code> function myplugin_delete_image_items( $postid ) { $args = array( 'post_type' =&gt; 'myplugin_image_item', 'cache_results' =&gt; false, // Di...
<code> get_posts() </code> simply uses a <code> WPQuery </code> object and sets a few default values. In general the values it sets make it mildly more performant. But I wouldn't worry to much about it. <code> get_posts() </code> is simplier so as a rule of thumb if you don't need any of the more involved features of <...
WP_Query or get_posts?
wordpress
If the contributor has already published two or more posts I show a maximum of 5 of them in the post-single.php using this code <code> &lt;?php echo do_shortcode('[latestbyauthor show="5"]'); ?&gt; </code> I have a text that introduces the code (other posts by the same author) This works fine if the contributor really ...
Simpler than using the <code> $wpdb </code> class would be to use <code> count_user_posts() </code> . For instance: <code> $min_posts = 2; if( count_user_posts( $post-&gt;post_author ) &gt;= $min_posts ) { // display the user's posts } </code> This assumes you're in The Loop, or at the very least that <code> $post </co...
If contributor has published 2 or more posts then show otherwise hide
wordpress
I have created a custom post type, but I do not want it to have a permalink. By default, after entering post title, it creates a perma link. I do not them to be generated. From my reading, it is said that custom post type, will have a permalink and there is no way of disabling it. Is there a way that I can prevent the ...
<code> &lt;?php add_filter('get_sample_permalink_html', 'my_hide_permalinks'); function my_hide_permalinks($in){ global $post; if($post-&gt;post_type == 'my_post_type') $out = preg_replace('~&lt;div id="edit-slug-box".*&lt;/div&gt;~Ui', '', $in); return $out; } </code> This will remove: Permalink itself View Post butto...
disable permalink on custom post type
wordpress
I'd like to develop a plugin that allows me to have custom user pages. I really like the way the author archive template handles the URL: /author/username. I don't want to rewrite the <code> author_base </code> as I'd like to keep that functionality in place untouched. I'd like to replicate that clean URL layout in my ...
I found the answer to this from @bybloggers answer found here. stackexchange-url ("stackexchange-url I modified his code very slightly to tailor it to my needs, but this is the code that worked for me and was exactly what I was looking for: <code> // Create the query var so that WP catches the custom /member/username u...
Creating a custom public user page
wordpress
In one file (test_ajax.php) I have a which on change loads another page (registration_form_race_type.php) with a short message via jQuery Ajax(). It works fine when "test_ajax.php" is accessed via its absolute URL which is : <code> http://46.20.119.207/~asuntosf/wordpress_test/wp-content/themes/test_ajax/test_ajax.php ...
I advice to use the wp built-in ajax. it allows avoiding many problems and brings many benefits. an example that I wrote to illustrate the 2 approches: stackexchange-url ("Dynamically changing navigation links (next and previous) via AJAX") I am here to provide with explanations good luck
jQuery Ajax() doesn't work when the page is accessed as a WordPress template page
wordpress
I have this script to get the ancestors ID <code> //Get root ID $post_id = $post-&gt;ID; $ancestors = get_post_ancestors($post_id); </code> I would like to make a redirection if it's empty to a specific page ID so no one could be on a page with no ancestors. How ?
The simple answer is <code> wp_redirect($url); </code> , but it's a tricky beast to use as you can only use it before any page output. So basically, what you have would need to be right at the top of your page This example is making the assumption that you are using this in <code> single.php </code> ? - <code> $post_id...
Redirect to a page if ancestors is empty
wordpress
I am building a responsive wordpress theme that allows for a custom banner image to be uploaded to each page. However, because of the responsive nature of the theme I need to set the images as background images using css to achieve the right effect. But, I do not want to throw random css styling into my html markup. Is...
The best way I found to solve this issue was to have PHP write the CSS styling I needed in-line. I know it is not best practice in terms of maintainability as it might be confusing to someone else coming into the project later on. However, it was a personal site so I will be the only one updating it. And it was the sim...
Is there a good way to use CMS images with CSS
wordpress
Is it possible to redirect from a permalink (a single article) to that same post in a relevant category page, which might be paginated? So when people visit <code> http://domain/post_number </code> they get redirected to <code> http://domain/category/page/2/#post_number </code> ?
I found a solution that works! Code can be improved, but this is a start. Put this in <code> single.php </code> : <code> &lt;?php /* 1. First check to see if single is in the category that is not allowed to be viewable through the single template: */ if (in_category('in-het-kort') ) { /* 2. Do a loop to determine how m...
Redirect single article permalink to paginated category page
wordpress
I have an issue with Canonicalization where on Custom Post Types say for example: /custom-post-type/{post_id}/fake-post-name/ is loading up but not redirecting to : /custom-post-type/{post_id}/real-post-name/ It basically is allowing anything to be after post id and load that URL instead of redirecting to the correct o...
Think ive solved it and can't believe what it was! On my rewrite rule I had: <code> add_rewrite_rule( 'custom-post-type/([0-9]+)/([^/]*)/?$', 'index.php?post_type=customposttype&amp;p=$matches[1]', 'top' ); </code> Adding in and passing the post_name for the custom post type got it to start redirecting. <code> add_rewr...
Canonicalization + Custom Post Types not working as expected
wordpress
Does anyone know if there is a way to change the callback function for a tag-like custom taxonomy so that it breaks terms after a semicolon instead of a comma? I realize I can stackexchange-url ("rewrite the whole meta box,") but I'd rather not if there's an easier way.
The tag delimiter is made translatable : <code> $comma = _x( ',', 'tag delimiter' ); </code> So this can be changed with a simple filter: <code> add_filter( 'gettext_with_context', 't5_semicolon_tag_delimiter', 10, 4 ); function t5_semicolon_tag_delimiter( $translated, $text, $context, $domain ) { if ( 'default' !== $d...
Separate tags with semicolon
wordpress
I'm currently running <code> 3.6-alpha-23495 </code> and want to go back to the latest stable (currently <code> 3.5.1 </code> ). The site is now up and running. The reason that I'm going to downgrade is that the following error is appearing: <code> Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to ...
The steps are mostly from this Codex article, Updating_WordPress#Manual_Update , but in this case a prior database backup is essential. This is what I do: Upload the latest WordPress version to a temporary folder, <code> /public_html/new-wp </code> This upload should not contain the folder <code> /wp-content </code> no...
Downgrade from latest nightly build to latest stable version
wordpress
I have what seems to be a rather troubling issue with the get_theme_mod function in the latest version of Wordpress. Only on particular servers (of which meet all Wordpress requirements) the function won't return the saved value that I can see stored in the database. However if I specify a default value for the functio...
I had the same issue.. using <code> type=option </code> and then <code> get_option </code> din't work either. Testing with another option item and works.. and testing with <code> MYTHEMENAME_THEME_OPTION </code> without the bracket for item and got an Array so I guess is the right way. So just a tip for those who found...
Issue with get_theme_mod returning a blank value instead of the saved value
wordpress
What is the right way to issue commands in wp-admin? My plugin imports data from a set of RSS feeds via a cron job. Thats all working good. I've set up a custom settings page to change parameters, and wanted to add an "Update Now" button so the user could force a manual refresh. I need a few other commands as well. Wha...
Always wait for <code> init </code> or <code> wp_loaded </code> , so you know all needed functions and classes are available. <code> add_action( 'wp_loaded', 'plugin_prefix_start' ); function plugin_prefix_start() { if (isset($_REQUEST['action']) &amp;&amp; $_REQUEST['action'] == 'update') { doUpdate(); } } </code>
Issue plugin commands in admin settings page
wordpress
Running 3.5.1. Is there an easy way to display my most recent post in its entirety and only display excerpts for my older posts on my home page?
This is the basic idea behind what you want. Extend/Customize to your liking. <code> if ( have_posts() ) : while ( have_posts() ) : the_post(); the_title(); // Incrementing a not instantiated variable results in 1 // so there's no need to set it to 0 beforehand if ( 0 &lt; $is_first_post++ ) the_excerpt(); else the_con...
Display most recent post in full, excerpts of older posts
wordpress
I'm having an issue that I can't find anybody else talking about anywhere. I have a wordpress multisite setup utilizing sub-directories. It's running on Debian Squeeze, and it's powered by nginx, php 5.4, and php5-fpm. Currently I am using the batcache plugin and the advanced apc caching plugin from mark jaquith. The B...
Alright I figured it out. Thank you guys. What it came down to was a little snippet of code I put in a while back to redirect a user to the home page if not logged in.... stupid me. I really appreciate your help in this though. By disabling everything but wordpress (all plugins, caching, everything.) it still happened....
Nginx Multisite redirects (incorrectly) on Chrome IE and Mobile, but works (correctly) on Firefox
wordpress
You can do a multipage post by using the <code> &lt;!--nextpage--&gt; </code> inside the post. The question is: How can I display the whole post (not paged) for this post.
Well, you can turn it off completely or use the following code along with some sort of conditional statement to switch it on or off. The multipage part is set up in the <code> setup_postdata() </code> function in <code> wp-includes/query.php </code> . There's an action at the end of the function called <code> the_post ...
Show all parts in multipage post
wordpress
I am using this snip of code to get rss feed on my dashboard as widget. It becomes problematic when it displays 5-6 different rss feeds which makes me run down deep. How can I add 6 different feeds in a single dashboard widget with scroll bar? Thanks <code> add_action('wp_dashboard_setup', 'my_dashboard_widgets'); func...
Yes, @toscho is right, the <code> url </code> works with an array of feeds adresses. And if you have 5/6 feeds, the total of items should be 20/24. For clear separation, I think it's better to run the <code> wp_widget_rss_output </code> function <code> n </code> number of times, and prepare a previous array with titles...
Different rss feeds in a single dashboard widget
wordpress
I created a Theme Options page where the user can edit some of the theme settings. Now I'm trying to save this options asynchronously but it seems I have some problems integrating the handler file into WP. The Theme Options is a simple admin page nested under Appearance. When pressing the save button: <code> &lt;a id =...
Wordpress has a native AJAX file that should do all that you want, and this will ensure that all native WP functions are included. If you require additional functionality from <code> 'framework/AsyncAction.php' </code> , you can <code> include_once() </code> , as you do with <code> SettingsController.php </code> . See ...
Call to undefined function add_action()
wordpress
In my plugin I define a constant as follows: <code> define('DEFAULT_NUM', 5); </code> I also define a constant representing the name by which I want to refer to this number: <code> define('DEFAULT_NUM_NAME', 'numitems'); </code> My plugin has a shortcode that uses these values as follows: <code> function do_something($...
You can do that, but you shouldn’t: Keep the global namespace clean. Each name in the global namespace is a collision candidate. Making a variable global, a constant or a function increases the likelihood of a collision, no matter how good your prefixes are. stackexchange-url ("Constants are the slowest") global types....
Get variable value based on string constant
wordpress
I'm experiencing a problem with the following piece code: <code> global $wp_query; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $filter_args['paged'] = $paged; $filter_args['posts_per_page'] = 2; $args = array_merge( $wp_query-&gt;query_vars, $filter_args ); query_posts( $args ); </code> This code is...
It has to do with the posts_per_page being 2 and the backend WordPress Settings being a greater value. If you set your WordPress Settings to 2 it will work. But you may not want all your pages to have two posts. In that case you can alter the query using the code in this answer, stackexchange-url ("Pagination Throws 40...
WooCommerce custom query and paging: Not Found error
wordpress
Can someone explain how to make embed shortcode responsive? http://codex.wordpress.org/Embeds
Originally posted by bainternet take a look at this wordpress.org/extend/plugins/responsive-video-embeds Thats a perfect plugin.
Responsive Embeds using default embed shortcode
wordpress
I'm currently creating a website that uses several content types, (e.g. books, movies, shows) as well as a key taxonomy term (e.g. status, with values of owned and wishlist). My question is, in a custom template how do I create a loop that queries only one taxonomy value across multiple custom post types (i.e. a single...
You can do this with an array of post types and a tax query for your term. The question you linked had special requirements as only one of the post types used the taxonomy. <code> $args = array( 'post_type' =&gt; array( 'books', 'movies', 'shows' ), 'posts_per_page' =&gt; -1, 'tax_query' =&gt; array( array( 'taxonomy' ...
Display all posts for taxonomy term across multiple custom post types
wordpress
I'm making a custom post type that I want to use in the form of a plugin - all pretty straight forward. However, I want the archive page for this post type to look slightly different in the content area - how would I achieve this without having to ask the end user to move files to their template directory? I hope that ...
Use <code> archive_template </code> filter in your plugin to override archive templates for a given post type, for example, <code> movies </code> : <code> &lt;?php function get_movies_archive_template( $archive_template ) { global $post; if ( is_post_type_archive ( 'movies' ) ) { $archive_template = dirname( __FILE__ )...
Hooking in to an archive page?
wordpress
Basically every time that I publish a post I want that a random image from my wordpress database be set as the feature image for that post. Can someone help me with this please!
Here is a way: <code> // listen for post being published add_action('publish_post', 'dreis_random_featured_image'); function dreis_random_featured_image() { global $post; // find one random image $args = array( 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'post_status' =&gt; 'inherit', 'posts_per_pag...
Set featured image randomly from Wordpress Database on post submission
wordpress
I am getting the following error when with the code that I wrote for my plugin: Error: Fatal error: Call to a member function get_error_code() on a non-object in .../wp-login.php on line 335 I've tried to do a var_dump($errors) inside wp-login.php and it returns NULL. My Plugin: (Adds registered users to an external db...
Your function must return the variable <code> $errors </code> – even when there is no new error in your logic. <code> 'registration_errors' </code> is a filter, and filters always expect a return value. Without that your function returns <code> NULL </code> , and that is what <code> var_dump() </code> found. So the bas...
Error: Call to a member function get_error_code() on a non-object
wordpress
How to add version of <code> style.css </code> in WordPress like below i can do in Joomla. <code> &lt;link rel="stylesheet" href="/templates/example/css/style.css?v=1.2"&gt; </code> i know that the <code> style.css </code> will load dynamically. please help me to how to do that.
Version number is a parameter of <code> wp_enqueue_style() </code> . Per the Codex, here are all the parameters that <code> wp_enqueue_style </code> accepts. <code> wp_enqueue_style( $handle, $src, $deps, $ver, $media ); </code> So for example to load a stylesheet with a version number you'd do the following: <code> fu...
how to add version of style.css in wordpress
wordpress
I'm new for WordPress. I'm using following code, <code> &lt;div id="cat_list"&gt; &lt;?php wp_dropdown_categories(array('show_option_all' =&gt; 'Categories') ); ?&gt; &lt;/div&gt; </code> And my JavaScript is, <code> &lt;script type="text/javascript"&gt; var dropdown = document.getElementById("cat"); function onCatChan...
You can try this <code> &lt;script type="text/javascript"&gt; var dropdown = document.getElementById("cat"); function onCatChange() { if ( dropdown.selectedIndex == 0 ) { location.href = "&lt;?php echo get_option('home');?&gt;"; }else if ( dropdown.selectedIndex &gt; 0 ) { location.href = "&lt;?php echo get_option('hom...
go to home page when i select default in select-box
wordpress
My client has asked me to create an about me section which will include a picture, job title and description for each team member as floated elements. They also want it to be as easily updateable as adding a post to a blog. So if they wanted to add a new team member within the same page, they will want to upload the im...
I found this WpTuts+ article about Custom Post Types for you. This is an article that will explain what exactly Custom Post Types are and how to accomplish creating one. This will help you along. Also, I found this wpbeginner article about creating custom archive pages. You can use this article to create the custom pag...
Allow certain part of a page to be easily updated for client?
wordpress
I created two custom taxonomies. I created them using identical code and then finding and replacing the "name" with "name2". I've then looked at the post type page and there are two tag boxes to choose tags in. However, one div is called "namediv" and the other is "tagdiv-name2". This would suggest that one is a catego...
WordPress uses the <code> category </code> -style meta box to handle <code> hierarchical =&gt; true </code> taxonomies and the post tags meta box for "flat" taxonomies. The CSS in the admin UI is just ... "grown", so names like those don't change until they really need to. <code> category </code> and <code> post_tag </...
Why is my taxonomy have a category style div id?
wordpress
I altered the following code from Ashfame: <code> add_action('pre_get_posts', 'block_cat_query' ); function block_cat_query() { global $wp_query; if( is_home() || is_search() || is_tag() ) { $wp_query-&gt;query_vars['cat'] = '3'; } } </code> This code DOES work to filter posts from category #3 only on the home, search ...
If the only issue you want to correct is the output of <code> single_tag_title </code> , you can correct the value via a filter by grabbing the tag query var directly: <code> function wpa90852_fix_tag_title(){ $tag = get_term_by( 'slug', get_query_var('tag'), 'post_tag' ); return $tag-&gt;name; } add_filter( 'single_ta...
Show only one category in main query, issues on tag page
wordpress