question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
The following URL seems to work for cats and tags only. <code> yoursite.com?cat=2&amp;tag=bread1+bread2 </code> what if you wanted to get into custom taxonomy and terms and do something similar? is there an equivalent to something like the following? <code> yoursite.com?taxonomy=food&amp;tag=bread1+bread2 </code>
This should work : <code> yoursite.com/taxonomyname/bread1,bread2 </code> So for example, on my site, I actually use : <code> mysite.com/location/barcelona,paris </code> And I get a list of all posts tagged with Barcelona or Paris
querying posts by custom taxonomy terms right from a querystring based URL
wordpress
I've added a couple of custom fields to the Edit Media screen, but when these are displayed in the WP Media Thickbox (when adding images from the Edit Post screen, for example), the styling is gone. Is there a hook to add my custom CSS to the Thickbox Iframe when it loads?
In WordPress 3.5, this hook works for me: <code> add_action( 'print_media_templates', 'wpse_75746_print_style_35' ); function wpse_75746_print_style_35() { ?&gt; &lt;style&gt; .media-modal-content, .media-sidebar { background: #FFF2D4 !important; } &lt;/style&gt; &lt;?php } </code> In 3.4.2, this is the one: <code> add...
How to Add Custom CSS to the Media Thickbox?
wordpress
This question is a little hard to explain but i will try to be as clear as i can: I have a custom theme that i am presently working on, within this theme i have added a top level menu in wp-admin with 5 submenus below it. In one of these submenus i wish to add custom post types where admin user can create and edit post...
Register the post type without a UI ( <code> 'show_ui'=&gt;false </code> ), then you will have to to create a form on your submenu page(s) and one or more handlers for those forms. <code> wp_insert_post </code> / <code> wp_update_post </code> can handle the post insertion if you give them the right information. Based o...
Usage of custom post types in a custom admin menu
wordpress
I have a basic archives.php file. I was trying to get it to display only posts from category 1. When I do query_posts('cat=1'), the URL is then ignored and all posts in category 1 are displayed. For example, lets say I have one post in category 1: it's called "testing post" and is dated November, 1, 2012. Lets say I ha...
First: don't use <code> query_posts() </code> , ever. Second, to create a category archive index page template for a specific category, refer to the Codex entry for the Template Hierarchy : <code> category-{slug}.php </code> <code> category-{id}.php </code> <code> category.php </code> <code> archive.php </code> <code> ...
How do I make archives.php for one category only?
wordpress
I am using the following code in <code> functions.php </code> for adding a custom meta box. The custom post type is <code> themes </code> . I want to add more post types, how can I? <code> add_meta_box( 'my-meta-box-id', 'Demo &amp; Download', 'cd_meta_box_cb', 'themes', 'normal', 'high' ); </code>
Whenever in doubt about a WordPress function, consult the Codex. http://codex.wordpress.org/Function_Reference/add_meta_box There, you'll see that you need to add one meta box to each post type. <code> add_action( 'add_meta_boxes', 'myplugin_add_custom_box' ); function myplugin_add_custom_box() { add_meta_box( 'myplugi...
How to add a Custom Meta Box for more than one Post Type?
wordpress
I have a loop setup to display future posts but would like to set up an if statement where if there are no future posts, it will show a certain amount of published posts. My current query below: <code> &lt;?php query_posts('posts_per_page=5&amp;order=ASC&amp;post_status=future'); if ( have_posts() ) : while ( have_post...
example: <code> &lt;?php query_posts('posts_per_page=5&amp;order=ASC&amp;post_status=future'); if ( !have_posts() ) query_posts('posts_per_page=5&amp;order=DESC&amp;post_status=publish'); if( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt; </code>
Display old posts if no future posts exist
wordpress
I'm trying to filter out the excerpt by character length for a plugin called "List Category Posts". I've been trying to get the excerpts working for the past week, but nothing is doing the trick. The plugin actually comes with a feature that allows you to post the excerpt or not, then filter it by character length.. by...
You need to have <code> 'excerpt' =&gt; 'yes', 'excerpt_size' =&gt; '100', 'content' =&gt; 'no' </code> ... when <code> get_excerpt </code> runs. You can set <code> $params </code> like that but what you posted is not all of the code. It is using <code> $this </code> which means it is part of a class (or you'd get erro...
Excerpt Length & List Category Posts Plugin
wordpress
I want to get the current category details that the user is on in category.php. <code> $category = get_the_category(); $slug = $category[0]-&gt;slug; // Why is this an array ? </code> In most cases (where there are no sub-categories) it returns and array of single length. But if there are sub-categories it (parent cate...
You are using the wrong function. Try: <code> $thiscat = $wp_query-&gt;get_queried_object(); var_dump($thiscat); </code> I don't know exactly what you want to do with this information but you will get an object (stdClass) with ~15 items in it. You should be able to find what you need.
Get current category details the user is currently on in category.php
wordpress
I'm trying to add an admin alert that reminds the user to install a certain plugin in case it is missing. I have found a way to generally add an alert box: <code> function addAlert() { ?&gt; &lt;script type="text/javascript"&gt; $j = jQuery; $j().ready(function(){ $j('.wrap &gt; h2').parent().prev().after('&lt;div clas...
To check if a plugin is installed and activated, use the <code> is_plugin_active() </code> function. Note that you need to include this function first on the front-end before you can use it: <code> include_once ABSPATH.'wp-admin/includes/plugin.php'; </code> Avoid <code> function_exists() </code> for doing the check. P...
How to add an admin alert for missing plugins
wordpress
I have a client that wanted two "main menus" and we needed to programmatically display whichever menu contained the current page. How can I do that? Ex: We're on the "About" page. Figure out which of the two menus contains the "About" page and show that one.
Here's the function I wrote to figure this out. You give it a menu slug/name/ID and post/page ID and it returns <code> TRUE </code> if that post/page is in the specified menu and <code> FALSE </code> otherwise. Then it was just simply a matter of a quick if/else statement to check against the two menus and display the ...
Check if page is in a certain menu
wordpress
I have input value " <code> &lt;iframe&gt;....&lt;/iframe&gt; </code> " (param 'post_content'). When i execute wp_insert_post, function cut off my tag. How to disable HTML filter in wp_insert_post ?
You could use call kses_remove_filters() before saving and call kses_init_filters() afterwards, but pay attention it will also remove filtering from title, excerpt and comments, So what you should do is just unset the content filters. <code> // Post filtering remove_filter('content_save_pre', 'wp_filter_post_kses'); re...
wp_insert_post disable HTML filter
wordpress
I've created a custom taxonomy for my posts, and I was wondering if there is a way to add an extra input field (a text input) for every taxonomy term inside the edit post panel. What I want is not a simple taxonomy meta field, because meta fields are always the same for each term in each post. Here's an example of what...
This is not a taxonomy field you need, because as you described, the name of the field will stay constant for every category, but its value will change for every post. So the field should be attached to the post, not to the category. What you actually need to use is a post custom field, that you could name (internally)...
Is there a way to add a custom input field for every taxonomy term in WP post editor?
wordpress
I have a very big multisite. And I got a request to enable option that multiple users can use the same email. I found a plugin "Allow Multiple Accounts" which doesn't work properly. I should figure out some other solution for that. I know that I could use something like adding +sometext to every email, so it will show ...
You can use <code> wpmu_validate_user_signup </code> filter to remove the error and then define <code> WP_IMPORTING </code> just to skip the <code> email_exist() </code> check in <code> wp_insert_user() </code> function: <code> add_filter('wpmu_validate_user_signup', 'skip_email_exist'); function skip_email_exist($resu...
How to use same email for multiple users
wordpress
When I am putting a WordPress value inside the attribute tag, for example, the following method does not need <code> esc_attr </code> e.g. <code> // JS code alert('&lt;?php echo get_bloginfo('name');?&gt;'); </code> the following method does need <code> esc_attr </code> <code> // JS code alert('&lt;?php echo esc_attr($...
You can look at the Codex . Encodes &lt; > &amp; " ' (less than, greater than, ampersand, double quote, single quote). Will never double encode entities. Given that, arguably, both of those strings need sanitization . Imagine a site name like <code> &gt;&gt; "My" Website's Great Title &lt;&lt;" </code> Also, since you ...
When do I need to use esc_attr when using WordPress internal functions
wordpress
I would like to customise the "Image browser" template in particular. I'm trying to make clicking on an image redirects to the next image in a gallery, just like how Facebook image browser works. (This is not a cosmetic change with CSS - CSS change is not what I mean by customising the tempaltes) I can always edit <cod...
One can do that by copying <code> imagebrowser.php </code> from / <code> wp-content/plugins/nextgen-gallery/view/ to yourthemedirectory/nggallery.php </code> If you want to customise other templates, you can do the same too. Some more information can also be found here .
How to modify/ customise NextGen Gallery's templates?
wordpress
I have posts which have a custom field date in the format yyyy-mm-dd. What Im trying to do is list all the posts for a specific year on the side of a single page based on the year in the custom field of this post and separated into months. So for example if the post has a custom field date of 1990 then I want to list a...
Mysql's Month function can help you on this. Assuming that your meta value is in SQL date format. <code> ORDER BY MONTH($wpdb-&gt;postmeta.meta_value) ASC </code>
Custom Query based on custom field of a single post
wordpress
I have few posts which have a dropcap shortcode wrapped around the first character like so: <code> [dropcap]T[/dropcap]his is a dropcap. </code> The replacement for this shortcode yields: <code> &lt;span class="dropcap"&gt;T&lt;/span&gt;his is a dropcap. </code> However, when I call the_excerpt() or get_the_excerpt() o...
You can make WordPress execute your shortcode in the excerpt by hooking into <code> get_the_excerpt </code> filter and overwriting the default <code> wp_trim_excerpt </code> function, which is responsible of stripping the shortcode tags from the excerpt as pointed by Chip: <code> add_filter('get_the_excerpt', 'do_my_sh...
the_excerpt() or get_the_excerpt with shortcode escape
wordpress
I have written a web-page which is a web-app (a simple card database using php, mysql, and styled with css3). The page works as expected. A friend of mine proposed me to use wordpress for everything else to save time on coding - welcome page, etc, so I decided to try it out. I need to lock the page to users with passwo...
Ok. M-R is right about using the full paths and not relative URLs. Make sure to do that. Create a page from wp-admin-> Pages named whatever you want. The title will be used to construct the URL so choose carefully Assign this page to your template "Tarot" The page should be accessible, but to everyone, logged in or not...
custom css and javascript not working on page defined as template?
wordpress
Hi all I am using Read More Right Here Plugin when i using the <code> &lt;!--more--&gt; </code> Tag it appears like <code> (more...) </code> I need to know how to change the <code> (more...) </code> to Read More` Anyone Much appreciated!!
Add this to your functions.php file: <code> function new_excerpt_more( $more ) { return 'Read More'; } add_filter('excerpt_more', 'new_excerpt_more'); </code>
Plugin:Read More Right Here , How to change the name (more...) to Read More
wordpress
I have a jQuery script that works fine within a WordPress post as long as I include a reference to the jQuery libarary within the post. <code> &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; </code> From what I have read this is not the proper way to reference jQuery as it is already include...
In order to use $ inside your script (You only need to change the wrapper of your script), use the following wrapper. <code> jQuery(document).ready(function($) { // $() will work as an alias for jQuery() inside of this function }); </code> Make sure you enqueue jQuery in one of your plugins or theme using <code> wp_enq...
jQuery inluclude still seems ncessary for script to work within post
wordpress
I'm overriding default WordPress gallery like so: <code> add_filter( 'post_gallery', 'my_gallery_shortcode'), 12, 2 ); function my_gallery_shortcode($output, $attr) { // some modifications to output here return $output; } </code> Modifications to $output have average complexity, can't say that they take too much or too...
If you think your shortcode is hurting performance (measure and you will know!), then you might want to consider caching its output in a transient. A good way to get a unique key would be to consider what could differentiate calls to your shortcode function: its name the attributes passed the site URL (in cases where m...
Should I cache default WordPress gallery shortcode output?
wordpress
I have a page template that allows users to create and update posts from the front end. I also am using 2 plugins, 1 that allows the user to rate posts from 1-5 stars and another that allows them to favorite the posts. I also have a page to allows the user to toggle between sorting the posts by date/category/post-type/...
Add this to your functions.php in your template folder. <code> &lt;?php //Set Default Meta Value function set_default_meta_new_post($post_ID){ $current_field_value = get_post_meta($post_ID,'YOURMETAKEY',true); //change YOUMETAKEY to a default $default_meta = '100'; //set default value if ($current_field_value == '' &am...
Add a default meta_value to new posts
wordpress
I'm trying to add some function to each loop called in the themes. What I'm doing is I add a function to count post view from here post views without plugin , to use the function I need to add this line <code> &lt;?php setPostViews(get_the_ID()); ?&gt; </code> to <code> single.php </code> , <code> page.php </code> , et...
You could hook into <code> template_redirect </code> and execute a helper function: <code> add_action( 'template_redirect', 'wpse_75558_count' ); function wpse_75558_count() { if ( is_singular() ) setPostViews( get_the_ID() ); } </code> To display the post views, you have to use a later hook. I would recommend <code> t...
Count singular post views automatically
wordpress
How can I insert my plugin code via shortcode inside post body in exact position? The problem is that wp engine inserts the plugin code BEFORE post body all the time. Can it be fixed? For example: I have some <code> [shortcode option="value"] </code> , that generates some text with image inside div container. When I pu...
I have had this problem before: shortcodes shouldn't display any content (using <code> print </code> or <code> echo </code> ), instead <code> return </code> the content to be outputted. If it's too much trouble converting all of your output statements, or you need to use a function that will always display the output, ...
Shortcode output appears before post body
wordpress
I was directed here from Stack Overflow -- We work with clients who have WordPress sites and one thing we keep struggling with is implementing HTML5 video across all browsers and devices in the WordPress environment. We've tried multiple plugins (JW Player, MediaElement, Sublime Video). It seems like each one has its o...
In an old project, I ended up writing my own. And working with WordPress library to feed the players (audio and video), so there's no foreign UI and a template builds the player with the proper attachment info. The audio player was implemented with JPlayer . The jQuery HTML5 Audio / Video Library jPlayer is the complet...
Practical Solutions to HTML5 Video on WordPress
wordpress
I want to make it so that logged in users can edit their information on a page in my site, so that I can avoid having them go to the admin side all together. I was thinking that I could create a shortcode (in functions.php) that would create the correct table and insert it into the page. I am just starting out with PHP...
This very Stack is a great stackexchange-url ("source") of stackexchange-url ("information"). It'd be a matter of adapting a stackexchange-url ("good answer") and making a stackexchange-url ("shortcode") out of it. For this case, it is better to create your own plugin , see: stackexchange-url ("Where to put my code: pl...
Create a shortcode that creates a form for users to edit their information
wordpress
I'm using the Taxonomy Images plugin to try to pull in the category images for custom categories on a page that displays all the categories my site has. For some reason, this code outputs the correct names and descriptions, but will only show one category image. I'd like the images to do what the other category feature...
Chip was on the right path, but closing the first loop would only publish one category instead of every category. What I ended up doing was closing the first loop and calling the ID and the img inside the second loop. <code> $imgs = get_option( 'taxonomy_image_plugin' ); $categories = get_terms('portfolio_category', ar...
PHP displaying wrong custom taxonomy images
wordpress
I have created a form. On success of the form, I am redirecting the user the their dashboard. Now, I want to be able to show a success message/notice on the dashboard. What is the convention to show such messages ?
When you redirect the user to the admin dashboard pass on a GET variable named "success_notice", for example. So you get a URL like this: <code> /wp-admin/index.php?success_notice=1 </code> . With that setup, just add the code that shows the success message on the dashboard only if that GET variable is set. <code> add_...
Show message on wordpress admin dashboard
wordpress
I am wanting to develop a premium Wordpress theme, and would like to know what is the best way to go on choosing a slider. I'm not skilled enough yet to write one from scratch. The ideal situation for me would be to use a Royalty-free slider (slides.js?) and then create different designs from that single slider. Is tha...
What about Anything Slider? I think it's open source. https://github.com/CSS-Tricks/AnythingSlider
Royalty-Free Sliders used in theme development
wordpress
I have a page like a welcome page which should be visited only once by each subscriber. After registration, they will redirected on my welcome page. Then I want that page not be available on same user for the second time, if the will try, I want them to be redirected. Is this possible?, should I use plugin? Thanks. :)
As mentioned in a comment above the cookie solution will not totally do the trick. If it's ok that they can revisited the welcome page from a different browser or if they delete cookies. This is fine. If not I would use the database. I think easiest would be to regard the time the user was registered. Like if the user ...
Redirect user on second visit on page
wordpress
I was turned down with stackexchange-url ("this question") because I get a php error and my question revolves around jquery, but when I take out the JQUERY everything works fine. * Again I'm creating a wordpress plugin. I am trying show and hide options. * Please any wordpress plugin creator with knowledge on how to im...
Why are you not using the built-in <code> enqueue_script </code> function? Simply put your custom jQuery code into a file called custom.js, save it into your plugin or theme folder, then enqueue it with jQuery as a dependency: <code> &lt;?php function custom_scripts() { if (is_admin()){ wp_enqueue_script( 'customjs', g...
Adding jquery using php function
wordpress
Currently I am using <code> &lt;!--nextpage--&gt; </code> to split a post into multiple pages, but I would like to change from <code> Pages: 1 2 3 4 </code> to <code> Next Page </code> and <code> Previous Page </code> links similar to what you see on this multipaged post In my <code> single.php </code> I have: <code> &...
Use the <code> 'next_or_number' </code> parameter: <code> wp_link_pages( array ( 'next_or_number' =&gt; 'next' ) ); </code> See the Codex for details .
Changing wp_link_pages() to "Next Page" and "Previous Page" buttons?
wordpress
Hi i'd like to order by multiple meta_keys want to make it order using these keys adminscore + user_like + _count-views_all + comment_count combine these keys how should i array order it?? i try this but not work.. <code> $args = array( 'meta_key' =&gt; 'adminscore' + 'user_like' + '_count-views_all' + 'comment_count',...
This line is wrong: <code> 'meta_key' =&gt; 'adminscore' + 'user_like' + '_count-views_all' + 'comment_count', </code> <code> 'meta_key' </code> only accepts string value. What you need is an additional meta key, e.g. "totalscore" that holds the total value of the scores you have for all the meta values. You can manual...
order by multiple meta_keys?
wordpress
I have a link on my post edit page (admin side) that calls up AJAX and jQuery to run a function inside my <code> functions.php </code> page. The link is wired up and calling the jQuery but I can't seem to debug whats going on inside my function thats being called from jQuery. I want the clicked link to delete custom me...
You aren't echoing anything so you aren't going to get much of an AJAX response. All you are doing with AJAX, really, is loading a webpage with Javascript. If the page doesn't print anything, you don't see anything. You don't need to return anything from AJAX but if you don't you will have a hard time working out wheth...
Debug whats going on inside a function called from AJAX
wordpress
I have a wordpress site, and I need to apply custom styles to one page, I see the custom styles option, and some of them work, but others get overwritten. Is there a way I can apply strictly my own styles to a portion of the page? Thanks, Brian
Open your theme functions.php. FTP/Server access: Navigate to your WP install and look in /wp-content/themes/[your theme folder] Via the WP Dashboard: Appearance > Editor, then look for Theme Functions (functions.php) in the right column Add the following to add a custom style sheet (replace "custom-style.css" with a b...
Complete Custom Style Part of Site
wordpress
I'm looking to get a number of records back from the database given a list of numbers and was wondering how I would use $wpdb-> prepare to do this (to take advantage of the sanitising vs SQL injection attacks that it gives me). A wrong way of going about what I'd like to achieve is <code> $wpdb-&gt;query($wpdb-&gt;prep...
<code> $wpdb-&gt;prepare() </code> use the same syntax for formatting like php's <code> printf() </code> . SSo you will need something like <code> ... WHERE post_id IN (%d,%d,%d) ... </code> This will fit for three ids. But what if we got more or less than three ids? We will use the php tools to create the needed forma...
How do you use prepare when asking for a list of id's
wordpress
I've just taken over a busy WordPress site that's got ~800 posts so far. The site's been around long enough that it was started up before post_thumbnails was available. They worked around that shortcoming with a custom field called 'Image' that held a value of the relative path to the image, e.g., "/wp-content/uploads/...
Had the same issue last week and here is what i did: <code> if (has_post_thumbnail()) //if the post already has a post thumbnail then just use that the_post_thumbnail($size = 'post-thumbnail', $attr = ''); else{ //if not then convert the custom field to the post thumbnail and display that $at_url = get_post_meta($post-...
Move from old custom field to new post_thumbnails
wordpress
After doing some extensive research, I've exhausted all my options and decided to actually ask a question here. I'm trying to get a filtered set of posts through AJAX using WP_Query and the tax_query parameter. I currently have one custom post type called "Vocabulary Terms" and two custom taxonomies called "vocabulary ...
Your code looks fine, but it's failing because your custom taxonomy is not getting registered anywhere in the action hooks of an AJAX call. My guess is that you are registering your custom taxonomies per the Taxonomies documentation , which tells you to add it to the "init" action hook. However, "init" doesn't get call...
Ajax and WP_Query/tax_query parameter
wordpress
My objective - Display some code on every page apart from 2 pages. Now this code works fine with only one page (if its not <code> is_home </code> , display code)... <code> &lt;?php if (!is_home()) { ?&gt; (some content) &lt;?php ?&gt; </code> ... but when I try to do it for two pages, the rule fails, and the code is di...
If you're testing against two falses you have to use the logical AND operator, because BOTH have the be false. <code> &lt;?php if( !is_home() &amp;&amp; !is_archive()) { ?&gt; (some content) &lt;?php ?&gt; </code>
problem with not displaying content on selected pages
wordpress
I'm currently running a blogroll on a site I'm working on by defining a variable with an array that has all the rss feed urls I want to pull from. Like this for example: <code> &lt;?php // Get RSS Feed(s) include_once(ABSPATH . WPINC . '/feed.php'); $rsslist = array( 'http://jordanshipman.lt11.com/rss', 'http://feeds.f...
I believe that you're looking for the <code> get_bookmarks() </code> function, which returns an array of bookmark objects. You could then implement this into your code: <code> &lt;?php // Get RSS Feed(s) include_once(ABSPATH . WPINC . '/feed.php'); $bookmarks = get_bookmarks(); $rsslist = array(); foreach ( $bookmarks ...
How do I get link URLs from the Wordpress links backend into an array?
wordpress
Bit of a wordpress novice and so just wanted to know the best way to do this. I am currently creating a wordpress site for a client. They have a Latest News section which is the primary 'blog'/posts page. The sidebar also displays the latest blog post. Now what I would like to do is create a Special Offers page, which ...
This is a perfect case for custom post types Simply create a post type called "specials" and you can use it just like your regular posts. EDIT: If you're new to WordPress and aren't interested in editing PHP, you can use a plugin like the Custom Post Type UI
How to create a second posts page which client can update
wordpress
I have php set up in a template file to check a form and see if 1 or more of 5 categories is selected. Based on which one is selected, I want the custom query I'm using to change in that the array for "category_name" changes depending on what is selected. I have gotten as far as defining the variables from the form but...
To make an array, separate your values with commas rather than concatenate them with periods. <code> $upostcat= array ( $video, $image, $audio, $writing, $event ); </code> That part is pure PHP. However, I notice you want to use the <code> category_name </code> "array". If you are talking about <code> WP_Query </code> ...
Using multiple variables to assign categories to an array
wordpress
I cannot find documentation or discussions on what is and how to use Drop-in plugins. The question was raised in this Q&amp;A, stackexchange-url ("Populate content on install"). Is a <code> wp-content/install.php </code> file that redefines the pluggable function <code> wp_install_defaults </code> a Drop-in plugin or n...
To answer your question, Yes In fact, there are many other functions you can override in that file, it's included as the first line of "wp-admin/includes/upgrade.php" &amp; there are many functions inside to be overridden Unfortunately, there is not too much information available regarding drop-in plugins but i'll try ...
Is wp-content/install.php a Drop-in?
wordpress
I have a multi-site install with buddypress on the main site. In the buddypress theme I've been able to override the default 'mystery-man' avatar using my custom buddypress theme. I simply have an images folder containing a replacement 'mystery-man.jpg' avatar. However, for the other wordpress sites on the network this...
The following code needs to placed in the <code> functions.php </code> file of any theme that has a replacement mystery man avatar. Adding it to <code> bp-custom.php </code> will not work in this instance. <code> &lt;?php // Use a differnt image than default mystery man function bp_custom_set_avatar_constants() { defin...
Subsite theme mystery man replacement with Buddypress on main site
wordpress
<code> //Display All Reviews function display_all_reviews( $query ) { if ( $query-&gt;is_home() &amp;&amp; $query-&gt;is_main_query() ) { $query-&gt;set( 'tag', 'reviews' ); } } add_action( 'pre_get_posts', 'display_all_reviews' ); //Movie All Reviews function display_movie_reviews( $query ) { if ( $query-&gt;is_home()...
For the sidebar bit, you should be using a new <code> Wp_Query </code> : <code> if ( $query-&gt;is_category('movies') ): $movies = new Wp_Query('tag=movie-reviews'); while ( $movies-&gt;have_posts() ) : $movies-&gt;the_post(); get_template_part( 'sidebar-reviews', get_post_format() ); endwhile; else: get_template_part(...
Wordpress Queries Not Working?
wordpress
I am beginner in wordpress &amp; i am working on my own blog ( http://cssground.com/ ). Right now i am facing an issue with the comment form. The comment form is visible to me &amp; it's work fine but is not visible to the user. Check this http://cssground.com/?p=30 I want a comment form like smashing magazine have. Pl...
You have commenting turned off for logged-out users. To change this setting, visit the Settings > Discussion page in your WordPress admin and uncheck the Users must be registered and logged in to comment box. Remember to update the setting by clicking the Save Changes button.
The comment login form is visible to me but not to the user
wordpress
I have a form on a page template that controls which posts show up on the page and how those posts are ordered. You can see what I mean here: http://www.theseattlevine.com/the-vine The questions I have is, how do I get the form to "remember" the selected values when the user uses the pagination at the bottom to go to t...
Use sessions <code> &lt;?php session_start(); // your fomrfields $post_fields = array( 'key_one', 'key_two', 'key_three' ); $form_data = array(); // copy needed form data from $_POST array foreach ( $post_fields as $key ) if ( isset( $_POST[$key] ) $form_data[$key] = $_POST[$key]; // save your form data in a session if...
Remember form field values with page navigation
wordpress
Is it possible for a WordPress site to display the users default Gravatar image (of chosen set, eg Retro, Identicon, etc), rather than the users uploaded avatar? As in, all user avatars next to comments would be a generated 'Retro' picture, regardless of whether they had a custom avatar at Gravatar or not. Screenshot o...
Found you can create the address manually to return the image from Gravatar, and pass in parameters to force default and theme. Combined this in part with @Sudar's answer, as well as the code from <code> pluggable.php </code> as the admin page will grab the ID not email from <code> $id_or_email </code> , so a check nee...
Force users to display default Gravatars
wordpress
I have the following code which gives be posts that are published in the last 100 days <code> function smbd_cats_by_days ($where = '') { $where .= " AND post_date &lt; '" . date('y-m-d', strtotime("-100 days")) . "'"; return $where; } add_filter('posts_where', 'smbd_cats_by_days'); </code> It is working fine. But now I...
I was afraid you wanted that one. stackexchange-url ("You can't really do that"). Follow the link for some workarounds. You could also set a variable or a constant in <code> functions.php </code> , or create a theme option for this. Then use that in your function. <code> function smbd_cats_by_days ($where = '') { // gl...
Using dynamic conditions in 'posts_where' filter
wordpress
I have some code that I would only like to be displayed on the sidebar when on the blog (the page that displays the posts). Now I am using this code... <code> &lt;?php if(is_page('37')) { ?&gt; ...Show code... &lt;?php } ?&gt; </code> The strange thing is if I enter any other page ID, it works as expected and shows the...
Got it! Turns out I should be using <code> is_home </code> which seems to work. More info here.. http://codex.wordpress.org/Conditional_Tags#The_Main_Page
Showing code only on Front Page "Posts Page"
wordpress
Is it possible to have a post not deleted from the MySQL database on deleting from the wp-admin panel ?
By default wordpress do not delete posts but rather moves them to the trash. They do not appear in the normal posts admin, but you can still see them in the trash and recover them from it.
Delete post from admin but not from database
wordpress
I've been storing all my theme options using Settings API for some time now and it's lacking one functionality. I have multiple pages (different servers) using my custom themes and I would love to move settings between them, I mean I'd like to export all the Settings API fields values from theme 1 and import them to th...
I just came across this wp.tuts tutorial a few days ago: Creating a Simple Backup/Restore Settings Feature <code> Lee Pham on Jun 22nd 2012 </code> In this tutorial, I’m going to show you how to create a simple backup/restore feature for your WordPress blog. With this feature, you can backup all options to another plac...
Import / Export Settings API fields values?
wordpress
I'm a bit confused. I have a custom-post-type named <code> wr_event </code> . I'm using the code underneath to loop through all "upcoming" events (defined by the meta_key `event_date). The problem I have now is that I want not only to show all upcoming posts, but all posts of the current year. <code> if ( have_posts() ...
Looking at what you've tried (in your commented code), I think you're close. I'm going to go out on a limb and guess that your <code> event_date </code> meta field is not stored as a numeric timestamp, which is what you were comparing against. Assuming it is stored as a text date like '2012-12-08' (and if not, it proba...
Custom Loop for custom post type. Compare by meta_value?
wordpress
I am trying to create a list of subpages of a parent page, which will appear in the sidebar of my wordpress site. This sidebar will appear on every page. So for example, I have a page with an ID of 54. This page has 7 subpages. I would like to display these 7 pages in the sidebar (just the titles), as well as any more ...
Simplest solution would be: <code> &lt;li&gt;&lt;ul&gt; &lt;?php wp_list_pages('title_li=&amp;child_of='.$post-&gt;ID.''); ?&gt; &lt;/ul&gt;&lt;/li&gt; </code> Use this code for more flexibility: <code> &lt;?php if ( is_page() ) { ?&gt; &lt;?php if($post-&gt;post_parent) $children = wp_list_pages('title_li=&amp;child_o...
how to list subpages in sidebar without widget
wordpress
Just to warn you, I am a complete PHP novice! I have one sidebar for all pages, however I would like to display certain elements on this sidebar for certain pages. I know there are a few widget plugins, however I am not using widgets, I am just coding in the sidebar.php file. I am aware I can do this... <code> &lt;?php...
So, you can use: <code> &lt;?php if( !is_page('37') ):?&gt; SHOW STUFF &lt;?php endif;?&gt; </code> P.S. ! (not parameter) Good tutorial - http://sixrevisions.com/web-development/php-conditional-statements/
hide block of code from showing on certain pages
wordpress
I'm writing a plugin to PPK encrypt non-public comment data as a second line of defence against crackers (one of my sites was recently compromised, so I have been rather spurred into action!). To achieve this, I am writing a meta comment value containing the encrypted email/IP for each comment, and once everything has ...
From Gravatar.com: All URLs on Gravatar are based on the use of the hashed value of an email address ( link ) Instead of storing an email adress in the comment data, you can store the md5-hash of that email adress. The email adress is encrypted and you can use gravatars. Use the filter <code> add_filter( 'preprocess_co...
Can I hook into get_avatar to supply a hash instead of an email?
wordpress
I have this code for the_excerpt : <code> function get_excerpt(){ $excerpt = get_the_content(); $excerpt = preg_replace(" (\[.*?\])",'',$excerpt); $excerpt = strip_shortcodes($excerpt); $excerpt = strip_tags($excerpt); $excerpt = substr($excerpt, 0, 640); $excerpt = substr($excerpt, 0, strripos($excerpt, " ")); $excerp...
First of all, WordPress already includes a function for displaying excerpts: <code> the_excerpt() </code> Secondly, your second piece of code isn't actually displaying anything. You need to use the <code> echo </code> statement for displaying text on the page. However, WordPress provides functions that actually display...
How to disable the_excerpt from one post
wordpress
Recently this solution was given (Thanks Mr.D), for this stackexchange-url ("Wordpress redirect to landing page if not logged in") thread <code> &lt;?php if($_SERVER['REQUEST_URI'] != '.../' || $_SERVER['REQUEST_URI'] != '.../'){ if(!is_user_logged_in()) { wp_redirect( 'http://www.mysite.com/landingpage', 301 ); exit; ...
What's happening is you're sending an unauthenticated visitor to a certain page. The code in that page also picks up that the user is unauthenticated, and sends them to the page that they're already on. Because the page keeps on sending the visitor to the same page, the visitor can't go anywhere. This is called a redir...
Landing Page - Redirect Loop?
wordpress
I want to update my feed just once a day. For example: I want to update the feed every day at 12:00 pm. How to do this without a plugin ?
The RSS feed is "updated" every time you post something new. If you want it to always be updated at 12pm then schedule your posts to always be published at 12pm.
Set RSS feed update time
wordpress
I am using the wp-polls plugin on my website. This plugin relies on using AJAX requests of the form http://www.myfakewebsiteurl.com/wp-admin/admin-ajax.php?action=polls&amp;view=process&amp;poll_id=2&amp;poll_2=8&amp;poll_2_nonce=420d75e659 When I log in, this request works fine: it pulls the poll results from the serv...
It only redirects when accessed directly, as do all files located in <code> wp-admin/ </code> . AJAX requests should work fine regardless of authentication status. Edit: <code> wp-admin/admin-ajax.php </code> should not redirect in any situation. Perhaps a plugin is redirecting all unauthenticated users to the homepage...
Why would admin-ajax.php redirect to the home page for logged out users?
wordpress
I have a custom meta boxe on a custom post type that has two date time fields. I will need to sort by these fields and also return posts that contain a date between two dates. Will WordPress automatically store these dates as varchars? What will be the best format to save the date in so that I can query them?
Post meta is stored in the <code> wp_postmeta </code> table . Values are stored as longtext, not as dates or integers. So your safest bet is to store these datetime fields as Unix timestamps. Then you can sort them using a meta query.
How to store datetime from custom meta box so that it can be sorted by
wordpress
I got this code that rewrite the url's for custom posttypes. It works but only for a depth where the posttitle is on the 5th segment. How can i adjust it so it accepts multiple depths? e.g.: <code> http://www.mydomain.com/post_type/category1/postname/ http://www.mydomain.com/post_type/category1/child1/postname/ http://...
After testing countless different structures i came up with this. It's manual work specifying each category but gives me more control. If someone comes up with a better solution, please let me know. <code> function mmp_rewrite_rules($rules) { //Product structure $newRules['product/(.+)/(.+)/(.+)/(.+)/?$'] = 'index.php?...
How to rewrite custom post type URL for multiple depths instead of one specific depth
wordpress
example: a user creates a group "cats" automatically a category "cats" would be created with the slug "cats" or a user creates a group "Fat Cats" automatically a category "Fat Cats" would be created with the slug fat-cats. I see there is a function wp_create_category : However,to be frank, i'm lost. Have tried, with ad...
There is an action where you can hook in. It is called: 'groups_created_group'. My idea is, that you hook into that and select the last group that was created. In database groups have a field called 'date_created'. So just read the name of the last one and create your group out of that. You have to write this in your f...
How to: When a bp Group created, automatically create a wp category
wordpress
I found the following two functions in order to highlight the current search term on my search-results page. <code> function search_excerpt_highlight() { $excerpt = get_the_excerpt(); $keys = implode('|', explode(' ', get_search_query())); $excerpt = preg_replace('/(' . $keys .')/iu', '&lt;span class="search-highlight"...
Usually, for filters like these content is passed into the filters, processed and passed back out. That is more or less the definition of a filter. Of course that isn't strictly true. You don't have to take input and you can wipe out "input" content if you want, though it is probably not a good idea most of the time. <...
Hightlight search-terms with functions does remove or disable other filters?
wordpress
I am currently building a site that will use newsletters, email notifications for new posts and email notifications for new comments on posts. I keep going back and forth between running this through third party sites and doing it solely through my WordPress website. I should mention, when I say third party, I am inclu...
If you predict many subscribers then going 3rd party is the only way, and by 3rd party I mean companies that specialize in bulk mail sending and have an API to control it. The API should satisfy your need for fine control. Wordpress.com and feedburner are not the kind of services I'm thinking of here. You can use WP fo...
What are the pros and cons to a WordPress run newsletter v. third party newsletter?
wordpress
I have a custom field for a large number of posts that contains the url for a youtube video. I used to grab the ID from the video and use that to build the thumb but in a new version I'm actually using download_url() for the custom built thumb image url from youtube and downloading it to my server. So I have to do this...
This will fire on <code> init </code> so you just need to refresh a page one time for it to work. I left out the actual value of <code> $new_value </code> -- you need to define that. <code> &lt;?php add_action( 'init', 'wpse_75308_update_video_meta' ); function wpse_75308_update_video_meta() { // Get all posts $posts =...
Create a new custom field for all posts based on current custom field
wordpress
I have a custom post type 'properties' that I'd like to control the HTML output for. For simplicity, let's focus on the archive view. As a basic example, here is what a loop looks like in an <code> archive.php </code> file: <code> &lt;?php while ( have_posts() ) : the_post(); ?&gt; &lt;h2&gt;&lt;?php the_title(); ?&gt;...
There're two very often forgotten action ref arrays: <code> loop_start/_end() </code> . Just turn on output buffering and you're ready to go. <code> add_action( 'loop_start', 'wpse75307_plugin_loop' ); add_action( 'loop_end', 'wpse75307_plugin_loop' ); /** * Callback function triggered during: * + 'loop_start'/`have_po...
How to control output of custom post type without modifying theme?
wordpress
I have this unique situation (though i doubt it no one has ever asked this before!). I want to track advertisement earnings from a service like Adsense per blog post and per page or per author . Why i want to achieve this ? we are quite a few number number of authors in this new website we are launching .In order to an...
Google Analytics offers this feature and pretty much the way you wanted it. In GA, in the Content Section, check the AdSense subsection ... specifically the AdSense Pages report. It tells you page wise which content has generated how much revenues. And yes, these reports are exportable in CSV format which open in Excel...
Track advertisement earnings per blog post and page in wordpress?
wordpress
I am creating a Wordpress plugin. I want to create 1 single shortcode that changes output based on the settings changed by the user on the admin settings page. So for starters, I have something like this below: <code> add_shortcode( 'my_shortcode', 'my_shortcode'); function my_shortcode($atts) { $atts = shortcode_atts ...
If you want to alter display based on admin options, you don't need to deal at all with the <code> shortcode_atts </code> ar the <code> $attributes </code> that are passed into your callback. The attributes passed in (and set by <code> shortcode_atts </code> ) are meant to alter the way a shortcode works based on how a...
Storing Options in a Shortcode
wordpress
Though I've been using my website's dashboard the last few days without installing any plugin nor touching any piece of code, today my dashboard (but not my website) is unavailable with a message "Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 30720 bytes) in /home/.../public_html/mysit...
(1) edit wp-settings.php [32M to 64M] (2) Try adding this line to your wp-config.php file: define('WP_MEMORY_LIMIT', '64M'); (you already have this, therefore ignore this step) (3) If you have access to your PHP.ini file, change the line in PHP.ini If your line shows 32M try 64M: memory_limit = 64M ; Maximum amount of ...
Memory issue only in dashboard
wordpress
Is there a possibility to count to how many categories a post belongs to?
Use <code> get_the_terms() </code> and count the resulting array: <code> print count( get_the_terms( $post-&gt;ID, 'category' ) ) . ' categories'; </code>
Count to how many categories a post belongs to
wordpress
I edited the Add New User Profile page to add some custom fields (I'm not using multisite). My question is if there is a way to send out an activation/confirmation email to new users once I manually add them in? Thanks!
Solved it by adding this code to save_extra_profile_fields() in add_action ( 'user_register', 'save_extra_profile_fields'); <code> $hash = md5( $random_number ); add_user_meta( $user_id, 'hash', $hash ); $user_info = get_userdata($user_id); $to = $user_info-&gt;user_email; $subject = 'Member Verification'; $message = '...
Wordpress Add New User - Send an Activation Email
wordpress
I'd like to know if there's any way to hook into WordPress update process and send <code> $_POST </code> variable to update server? I'm delivering plugin/theme updates from private server and I hook into this: <code> add_filter('pre_set_site_transient_update_themes', 'check_for_update'); </code> which works just fine. ...
Update &amp; the internal WP HTTP API A slightly modified version of stackexchange-url ("my answer to this question"), but also as a plugin that shows how it could work. Note: The code is not tested - I don't know your server setup, etc. - and just written out of my head. You'll have to test it, find the proper positio...
Hook into WordPress update?
wordpress
I created a custom WordPress plug-in that hooks onto 'save_post" using add_filter(). I need to do something with the post titles and whenever a user changes the title, my plug-in cannot get the new title until the post is updated a second time (without changing the title in the admin a second time). For example, I have...
The second argument of the <code> save_post </code> action contains the post data: <code> do_action('save_post', $post_ID, $post); </code> You can also hook <code> post_updated </code> which will let you easily compare the before/after data: <code> do_action( 'post_updated', $post_ID, $post_after, $post_before); </code...
How to get changed post title in my custom plug-in which fires when 'save_post' is called?
wordpress
Google search result does not show author information or thumbnail images. the source code look like this <code> &lt;link rel="author" href="https://plus.google.com/115911773396772351667/posts"/&gt; </code> procedure followed same like what google says. unfortunately the result doesn't appear. here is the website link ...
It's called Author Rich Snippets. Your link needs to look like <code> &lt;link href="https://plus.google.com/115911773396772351667?rel=author"/&gt;Your Name&lt;/a&gt; </code> The Simple Way To Set Up Author Rich Snippets There are a few things you need in order to step up Author Rich Snippets: A public Google+ profile....
how to show Author information in search results
wordpress
I am using the standard wordpress loop that looks like: <code> &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt; &lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt; &lt;?php endwhile; else: ?&gt; &lt;h2&gt;We're sorry...there is no content.&lt;/h2&gt; &lt;?php endif; ?&gt; </code> Then, what I want...
I recommend you use the <code> pre_get_posts </code> filter or ditch <code> query_posts </code> and use <code> WP Query </code> . That way you can easily use <code> category__not_in (array) </code> parameter and not mess any other loops up. <code> function exclude_category($query) { // this requires term id instead of ...
Query Posts Exclude Entire Category
wordpress
I have a list of products on a page and am trying to order them by a custom field called "price". Unfortunately, $3,950,000 is coming before $349,000. I've used a couple of codes but neither one is working. Does anyone have any suggestions? Thanks. Here's the first code I've tried. <code> $query = new WP_Query( array (...
You are storing your "price" (apparently) as human readable formatted currency. That makes it a string. And that means it is going to be sorted alphabetically, more or less, and not numerically as you need it to be. If you can store those values without the punctuation, and use <code> meta_value_num </code> -- your sec...
Order posts by price
wordpress
I don't even know if this is possible and my search terms in google are not doing any good. Since the site URL and blog URL are different I had to fix the post preview bug by giving wordpress it's own directory . Problem is, the site is being updated in pieces so it's part wordpress, part old school html, including the...
It is going to be hard to give a solid answer without knowing exactly how you've cobbled things together but a preview always has <code> preview=true </code> in the URL. Just check that. <code> if (isset($_GET['preview']) &amp;&amp; 'true' == $_GET['preview']) { // send the page to WordPress } else { // load index.html...
Detect if request is coming from wordpress conditional statement
wordpress
I'm trying to display related posts by a custom taxonomy and only have the solution for related posts using a category. <code> $orig_post = $post; global $post; $categories = get_the_category($post-&gt;ID); if ($categories) { $category_ids = array(); foreach($categories as $individual_category) $category_ids[] = $indiv...
okay now i found the code that makes it able to use a custom taxonomy to show related posts for a custom post type. $terms = get_the_terms( $post-> ID , 'product_tags', 'string'); is the custom taxonomy in which you should put to query all the tags in your custom post type 'post_type' => 'products' is the custom post t...
query related posts in a custom post type by a custom taxonomy
wordpress
Hi I wanted to change the default WordPress gallery short-code and make it a slider. <code> remove_shortcode( 'gallery' ); function gallery_filter( $atts, $content = null ) { extract(shortcode_atts(array('gallery_name' =&gt; ''), $args)); $args = array( 'post_type' =&gt; 'attachment', 'numberposts' =&gt; 3, 'post_paren...
this code removes the wordpress native gallery in which shows thumbnails and calls the permalink to attachment.php where it shows the image by itself. the following code makes it a slider using a easy slider with limited animation and transition effects. 1. Calls the arguments for the transition effect and call the js ...
change wordpress gallery shortcode to slider
wordpress
I'm not able to get nav menus to register - and I'm not sure what else to try when posted solutions are not working? I've tried the solution in this post: stackexchange-url ("register_nav_menus() won&#39;t register menus") And have also followed the instructions in: http://codex.wordpress.org/Function_Reference/registe...
In regard to this comment: I see - I had things nested incorrectly in my <code> functions.php file </code> - I found that the <code> register_nav_menus() </code> call should not be nested within the theme setup function ( <code> function hchw_setup() </code> ) To the contrary, inside a callback hooked into <code> after...
Problem with registering menus - What to do when other solutions aren't working?
wordpress
Normally, a MySQL database can be exported and imported using these simple SSH commands: Export: <code> mysqldump -u USERNAME -p DATABASE_NAME &gt; filename.sql </code> Import: <code> mysql -u USERNAME -p DATABASE_NAME &lt; filename.sql </code> But it's not that simple when it comes to WordPress. From what I see, addit...
It is that simple for Wordpress too. I use the following to back up my WP sites: <code> mysqldump -u &lt;user&gt; -p&lt;pass&gt; --quick --extended-insert &lt;db-name&gt; &gt; backup.sql </code> The mysqldump document gives the details on all the parameters. <code> --extended-insert </code> is quicker when updating a D...
How To Export/Import WordPress (MySQL) Database Properly Via Command-Line?
wordpress
I just need to know if this is the only way to install wordpress from live to localhost. I downloaded the files and database from live, then push the files folder to my htdocs folder, and uploaded the db through phpmyadmin and change the config file. Upto this point I think im on correct side. After entering <code> htt...
Update your <code> wp_options </code> table. Look for <code> siteurl </code> and <code> home </code> and change their values to point to your localhost, that is, <code> http://localhost/mylocalsite </code> . This should be enough to make your site work again. You don't need to find and replace all instances where the o...
Wordpress installation from live site to localhost
wordpress
I need to remove the 'Featured', 'Date' and 'Comments' from my Twenty Eleven child theme sticky post that I have on my landing page. I am finding it hard to find any information that show what functions I will need to override and what files they reside in. Does anyone know what I need to override and help point me in ...
<code> &lt;?php get_template_part( 'content', get_post_format() ); ?&gt; </code> is calling the content template, you'll need to edit that template view and remove the things you don't want. Or wrap them in if statements of some sort.
Need to remove 'Featured', 'Date' and 'Comments' from WordPress Sticky Post?
wordpress
There used to be a plugin called "WP-Custom" in Wordpress plugin base. Does anyone know what its new name or where I can get it? Wordpress shows no sign left of it.
According to the author's website , the plugin has been removed as it is no longer beneficial when custom post types are available. However, if you are so inclined, you can download it from the above page.
Where did the "WP-Custom" plugin go?
wordpress
Following the solution from Jeff @ stackexchange-url ("Custom permalinks - post type - hierarchical taxonomy&#39;s") I managed to rewrite my url's for custom taxonomy's. However i do have one thing that bothers me and that is a double slash in the output because of the separator. http://www.domain.nl/product/televisies...
After changing something i have the final code that makes it work. This is where you register the post types. (not changed) <code> register_post_type( "products", array( 'label' =&gt; CUSTOM_MENU_TITLE, 'labels' =&gt; array( 'name' =&gt; CUSTOM_MENU_NAME, 'singular_name' =&gt; CUSTOM_MENU_SIGULAR_NAME, 'add_new' =&gt; ...
How to fix a double slash in custom permalinks with hierarchical taxonomy's?
wordpress
I have a magazine format where a parent category is an issue, sub categories are the sections and the articles go into their respective sections. When viewing an article in a magazine, I would like to be able to scroll through all the articles in that issue not just the section the articles are in or the whole website,...
<code> You can use Ambrosite Next/Previous Post Link Plus(wordpress.org/extend/plugins/…) plugin for doing this. </code> Glad it worked for you :). Can you vote up for this
How to get Next/previous_post_link to go through articles in top parent category
wordpress
Can someone tell me how to direct a user to the main 404 file instead of having to print an error message saying "file not found" in single.php? For example: <code> &lt;?php if (!$myVar) { // go to 404.php and return an official file not found header } else { // show the following HTML } ?&gt; </code>
You can use the <code> locate_template() </code> function to include the 404 template. Remember to do this instead of using <code> get_header() </code> or generating any output; otherwise you will have a duplicate. <code> &lt;?php if ( ! $myVar ) { status_header(404); global $wp_query; $wp_query-&gt;is_404 = true; loca...
How to direct user to actual 404 page when a check is false in single.php?
wordpress
I'm trying to do something similar to this question here: stackexchange-url ("remove_action or remove_filter with external classes?") I'm trying to remove the <code> &lt;!-- This site is optimized with the Yoast WordPress SEO plugin v1.0.3 - http;//yoast.com/wordpress/seo/ --&gt; </code> message from the plugin. And be...
A simple way to achieve this (but without the Class approach) is by filtering the output of <code> wp_head </code> action hook using the output buffering . In your theme's <code> header.php </code> , wrap the <code> wp_head() </code> call with <code> ob_start($cb) </code> and <code> ob_end_flush(); </code> functions li...
Remove an action from an external Class
wordpress
I have Wordpress 3.4.2 set up on a Windows 2008 R2 server with IIS 7.5. I enabled multisite using subdomains and set up one additional site, call it child.example.com. I can browse to the main site at example.com just fine, but whenever I browse to child.example.com it tries to go to the default web site in IIS, which ...
I finally figure it out. I was missing a binding on my main Wordpress site in IIS. I needed to add one for the sub-site, in this case child.example.com, specifying the same IP. After doing that I could successfully browse to the sub-site. Presumably when IIS can't find any matching binding for the given host name, it j...
Multisite setup on IIS with subdomains
wordpress
the desire i want is similar on how facebook works; when a new content is being published, it pushes down the old post with the new posts on top. New Content (pushes down previous topics without reloading the page) Old Content 1 Old Content 2 Old Content 3 is that possible in wordpress?
The used term for this is "infinite scroll", there are plugins that may assist you to achieve this behavior, you can check this one: http://wordpress.org/extend/plugins/infinite-scroll/
how to refresh index page without reloading browser using ajax
wordpress
There are multiple ways to identify if a plugin is active (stackexchange-url ("here's one)") but how can we identify if a specific JetPack component is active, for example Photon ?
We just committed a new function to Jetpack Trunk, and it should be enabled in the next release, <code> Jetpack::is_module_active() </code> -- http://plugins.trac.wordpress.org/changeset/716884 Then you can just call: if( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'contact-form' ) ) {} Or at least, you wil...
How to tell if Jetpack's Photon is active?
wordpress
We have a multisite setup, the primary domain needs to have www.primary.net, and secure.primary.net mapped in wordpress so the primary site's content loads on both. The problem we are facing is secure.primary.com doesn't work. secure.primary.net always ends up at: http://www.primary.net/wp-signup.php?new=secure.primary...
Install WordPress MU Domain Mapping Plugin , and edit the <code> wp_domain_mapping </code> database table. Insert a new row for <code> blog_id </code> #1 manually, for example: <code> +------+-----------+----------------------+----------+ | id | blog_id | domain | active | +------+-----------+----------------------+---...
How do I park secure.primary.com on top of the multisite ID:1 domain: www.primary.com (primary multisite domain)
wordpress
I'm asked to set up a WordPress-based site, which is not intended to run as blog mainly but anyway we want to use the common article area sometimes. Now my client resents that the URL to an article or archive includes "/category/". He wants to make use of tags but categories are redundant since he only wants to have an...
By default, the URL to an article does not include "category". Only URLs to category archives do, so it sounds like something has already been re-configured. Anyway, to get the string you want, go to wp-admin-> Settings-> Permalinks and set the permalink structure to "/news/%postname%/". That will put the blog posts at...
Is the part "category" fixed to an URL to an archive or post?
wordpress
If I want to route a HTTP request through a local (alias: on the current server) Proxy, how would I go around this? The allowed Proxy settings for the <code> wp-config.php </code> are the following: <code> # HTTP Proxies # Used for e.g. in Intranets # Fixes Feeds as well # Defines the proxy adresse. define( 'WP_PROXY_H...
The proxy settings work just like a regular HTTP requests but in this case obviously routed through a proxy. In terms of WordPress the API's transport layers all support proxy connections(fsockopen, fopen, cURL, ). The things about proxy configurations are they come in several flavors and each setup is different so it ...
How to use the HTTP API with a Proxy?
wordpress
<code> Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 81 bytes) in /home/public_html/hol/wp-includes/meta.php on line 571 </code> I'm receiving this error when I try to log into my wordpress blog as admin. If I login anything else lower than level 3 everything works fine! I tried remov...
Turn off all plugins. Switch to TwentyTen. Then install the debug bar and helpers. Then switch back to custom theme - reload. Turn one plugin on - reload, next plugin - reload, etc.
In big trouble - Allowed memory size of 268435456 bytes exhausted
wordpress
I'm new to Wordpress and trying to take advantage of the framework as much as possible. On the front end, I want a centralized message area to display error, success, and general notices similar to how they're handled via admin_notices on the back end. I'm not seeing a similar hook for the front end. I guess I'm asking...
There is no such action in the front end (in a theme) by default. Simply use a custom action like <code> do_action( 'theme_notices' ); </code> and hook into this one.
Is there anything like admin_notices for front end?
wordpress
I have a multisite blog that will soon have an Akamai caching service sitting in front of it, serving cached content to visitors (15 minute TTL). I want to configure Akamai to exclude any important URLs that should never be cached (i.e., don't want to serve cached login/admin pages). Is there a compilation, or general ...
You should not cache anything in the admin so your examples are correct. A typical nginx reverse proxy cache is set to ignore <code> wp\-.*\.php|wp\-admin </code> Another option is to not cache logged in users by checking the wp cookies, but you probably don't have that level of control. ps. It is highly advisable you ...
Which WordPress pages/URLs should never be cached?
wordpress
How do i get the ID from the current custom taxonomy (category) the user is browsing? It uses a custom post type called "products" The categories are called "pcategories" With normal categories i would get it like this: <code> &lt;?php if ( is_category() ) { $cat= get_category( get_query_var( 'cat' ) ); $cat_id = $cat-...
I fixed it by using the following code: <code> $current_term = $wp_query-&gt;get_queried_object(); $termid = $current_term-&gt;term_id; </code> Works quite well
How to get the id from the custom category?
wordpress
This week I installed Wordpress 3.4.2 (Linux Centos + Apache2) and configured the network option using subdomains. Then I installed the MU Domain Mapping plugin, so I would be able to use it with domain names instead of subdomains. This works for one domain, however the second domain redirects to the subdomain. base si...
Check if the Primary option is selected for the second domain under domain mapping settings. It should say Yes under Primary in Settings-> Domains for that domain.
wordpress multisite domain mapping redirects to original subdomain
wordpress