question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
Morning! I have a call in my <code> functions.php </code> file to include a custom meta-box php file in my theme's directory called: <code> /metaboxes/home-meta.php </code> The code is as follows for the call: <code> add_action( 'add_meta_boxes_page','load_home_meta' ); function load_home_meta() { $post_id = $_GET['pos...
Problem #1: First problem: inside <code> home-meta.php </code> , pull all of your <code> add_meta_box() </code> calls outside of the <code> add_meta_boxes_home() </code> callback, and get rid of the callback and <code> add_action() </code> call. You handle this already, with the <code> add_meta_boxes_page </code> callb...
Custom metabox not working
wordpress
I created a custom WP query to collect products that have 3 different taxonomy values in them and sorted them by price using the following: <code> $my_products = new WP_Query( array( 'orderby' =&gt; 'meta_value', 'meta_key' =&gt; 'regular_price', 'order' =&gt; 'ASC', 'paged' =&gt; $paged, 'post_type' =&gt; 'product', '...
Your problem is in using as orderby value <code> meta_value </code> and thus the order is correct - from computer point of view. To get currect order from human point of view, try to use <code> meta_value_num </code> instead. You can read more in here: https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orde...
Wordpress Custom post query sorting does not work
wordpress
What is the best way to display the appearance number of a post in a query? For example, if a post is the first listed print #1. If it is third, print #3. Any direction is appreciated!
<code> $the_query = new WP_Query( $args ); while ( $the_query-&gt;have_posts() ) : $the_query-&gt;the_post(); echo('#' . $the_query-&gt;current_post + 1); // $the_query-&gt;current_post has the index endwhile; </code>
How to number the posts (ie #1, #2, #3) in a wp_query?
wordpress
I have a post type registered with this code, however <code> 'exclude_from_search' =&gt; true </code> seems to have no effect as I still find output in the search page. Am I making some mistake? <code> add_action('init', 'abundant_life_slides_register'); function abundant_life_slides_register() { $args = array( 'label'...
Your exclude_from_search is currently inside your nested labels array. You need to move it up.
register_post_type exclude_from_search argument not working
wordpress
Hi I am implementing a core plugin plus add ons. There is a settings page and I would like to hook some validation routines for the addon plugin into the core plugin's validation function. However it's not working. Can you point me in the right direction? Here's an excerpt of what I have: <code> register_setting( 'myp_...
<code> do_action() </code> does not use a returned value. It works more like the <code> onload </code> event in JavaScript: You cannot undo the load. To change a value you need filters . If you want to change the option content, hook into <code> pre_update_option_{$option_name} </code> very late (with a high priority p...
Implementing action correctly
wordpress
I'm writing a WP plugin that involves using shortcode. One of the missions is to display all (publish) posts that contain my shortcode regardless of their post type. Is there a built-in function for this? Thanks in advance.
WordPress isn't aware of your shortcode until it's rendered on the front end. So when WP sees it in the content and replaces it, that's when it's aware that your shortcode exists. It also promptly forgets about it afterward, of course. So there's no build in function to do what you're asking. The best you can do is pro...
Get all posts containing a shortcode
wordpress
need help regarding wordpress navigation i am using <code> if ( has_nav_menu( 'main_nav' ) ) { wp_nav_menu( array('menu' =&gt; 'guest menu' )); } </code> from back end if i keep the menu empty(do not any page/category to menu) it displays all the pages in menu on front end. i want it it to display nothing or by default...
See Function Reference/wp nav menu <code> if ( has_nav_menu( 'main_nav' ) ) { wp_nav_menu( array('menu' =&gt; 'guest menu', 'fallback_cb' =&gt; false )); } </code>
who to limit number of li in wp_nav_menu
wordpress
I have a network with more than 50 sites. I want to create one contact form (which means one shortcode) using contact form 7 or fast secure contact form. Then, I want to use that shortcode on all the 50+ sites so all sites use the same form. The problem is that when I try to use a shortcode of site A over site B, it's ...
A Must Use plugin could do the work. This is just an outline and has to be fully tested: <code> add_shortcode( 'global_form', 'shortcode_wpse_87634' ); function shortcode_wpse_87634() { // Main site, ID=1, that has the form switch_to_blog( 1 ); // Do your stuff $my_stuff = something(); // maybe do_shortcode // Back to ...
using 1 form shortcode (si or cf7) for all multisite sites
wordpress
I have this query... <code> &lt;?php $press = new WP_Query(array( 'posts_per_page' =&gt; -1, 'post_type' =&gt; 'individual', 'post_status' =&gt; 'private' )); if ($press-&gt;have_posts()) : while ($press-&gt;have_posts()) : $press-&gt;the_post(); ?&gt; </code> But my custom post-types are using custom taxonomy with a n...
No, there is no way to do this with default WP Core. @heathenJesus talks about meta data not taxonomies. See http://scribu.net/wordpress/sortable-taxonomy-columns.html for a proper solution. And a more thorough explanation of why this is not something built into Core: stackexchange-url ("Using wp_query is it possible t...
WP_Query orderby taxonomy term value (numeric)
wordpress
I'm just trying to add a simple bit of Show/Hide jQuery to a child theme. <code> $(document).ready(function(){ $("#openbtn").click(function(){ $("#openingtimes").toggle(300); }); }); </code> I've saved the above code in a file called <code> buttons.js </code> . I have then registered and enquequed the script using the ...
jQuery scripts in WordPress require no-conflict wrappers . Instead of this: <code> $(document).ready(function(){ $(#somefunction) ... }); </code> Use this: <code> jQuery(document).ready(function($) { // $() will work as an alias for jQuery() inside of this function }); </code> So, in your case: <code> jQuery(document)....
My jQuery is enqueued properly. So why isn't it working?
wordpress
I'm trying to display a title, featured image, and content from a page into a new template (that will contain content from several pages). I tried to just echo the variables as shown below, but right now it's only display the content and title+"array". Any ideas? Here is my current array: <code> &lt;?php $id = 2131; $p...
wp_get_attachment_image_src returns an array , not a single value. Please refer to this article for more info: wordpress.org/Function_Reference/wp_get_attachment_image_src Default Usage <code> &lt;?php $attachment_id = 8; // attachment ID $image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns an ...
Outputting content from page
wordpress
I'm using <code> wp_editor </code> to add wysiwyg fields to admin edit screens. Each wysiwyg lives within a draggable meta box. Since TinyMCE has issues with dragging, I'm using the following code: <code> // on the dragstart event tinyMCE.execCommand('mceRemoveControl', false, the_editor_id); // on the dragstop event t...
It turns out that TinyMCE has it's own <code> autop </code> setting, so if you kill it before the sort and then put it back you should be good to go! Check out the <code> autop </code> setting handling in this snippet: <code> &lt;script&gt; (function($) { // by default, wpautop will be true var wpautop = true; // this ...
TinyMCE strips line breaks on mceAddControl
wordpress
I have statistical shortcodes that return values [stat1 val="usa"] [stat2 val="europe"] [stat3 val="china"] [stat4 val="africa"] I struggle to create the shortcode that can sum the shortcode values so if stat1=1 stat2=2 stat2=3 stat2=4 [sumsc][stat1][stat2][stat3][stat4][/sumsc] it would return the value 10
You can try this: <code> add_shortcode('sumsc','sumsc_func'); function sumsc_func( $atts, $content = null ) { $sum=0; preg_match_all('/stat([0-9]+)/i', $content, $matches); if(isset($matches[1])){ $sum = array_sum($matches[1]); } return do_shortcode($content)." &lt;div&gt;The sum is &lt;strong&gt;".$sum."&lt;/strong&gt...
shortcodes inside shortcode to sum values
wordpress
Hi I have tried to optimize my website energyshop.se for a cpl of days but I cant seem to get it done. This is how my .htaccess looks like: <code> Header unset ETag FileETag None # Hantera och redirecta användare till en gemensam error-sia ErrorDocument 404 /psych/cgi-bin/error/error?404 # BEGIN Compress text files &lt...
My advice to you is not to worry about adding in the copious amount of .htaccess rules for forcing browser caching and setting correct expire time values for assets. If you download the W3 Total Cache plugin it handles adding all of the above into your .htaccess file for you. If you would prefer not to install the cach...
How do I edit the htaccess file to optimize my website?
wordpress
I am having an issue with the WordPress admin bar overlapping the twitter bootstrap (2.3.0) nav bar. I have tried this fix: <code> body.admin-bar .navbar-fixed-top { top: 28px; } .navbar .brand { color: #000 !important; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 30px rgba(255, 255, 255, 0.125); font-weight: bol...
stackexchange-url ("How to prevent the WordPress admin bar from overlapping with your Twitter Bootstrap navigation bar.") In response to: stackexchange-url ("WordPress admin bar overlapping twitter bootstrap navigation") Asked by: @TheWebs </code> If you are using Twitter Bootstrap with WordPress and have an issue with...
WordPress admin bar overlapping twitter bootstrap navigation
wordpress
When importing a feed into a custom post type does it make any difference if I store the feed description in the post_excerpt field versus the post_content field? Is there some processing that gets applied via WordPress when I save content to any of those two fields?
There is no difference in storing data into the <code> post_excerpt </code> field versus the <code> post_content </code> field. If you look at the source code (line 2700) you will notice both <code> post_excerpt </code> and <code> post_content </code> won't be filtered.
Saving into post_excerpt or post_content
wordpress
A client of mine wishes to not have to sort images uploaded into a post gallery, but instead rely on its filename for sorting (e.g. "01_sample.jpg", "02_sample.jpg"). This would save a lot of time for the client, and I'm wondering if this is possible to achieve using WP 3.5+ and the recent changes to Add Media?
When you or the client add the gallery shortcode, you can add an "orderyby" option to specify the order of the images. Per the Codex page on the gallery shortcode: <code> [gallery ids="729,732,731,720" orderby="title"] </code> ... will do what you're wanting.
Autosort uploads in galleries by filename
wordpress
I wish to change the default ajax loader for gravity forms. I have done this using the following code (link found here ): <code> add_filter( 'gform_ajax_spinner_url', 'cwwp_custom_gforms_spinner' ); /** * Changes the default Gravity Forms AJAX spinner. * * @since 1.0.0 * * @param string $src The default spinner URL * @...
Without testing, this should work (still use the add_filter bit): <code> function cwwp_custom_gforms_spinner( $src ) { global $post; if( $post-&gt;ID == $id ): // use whatever page identifier/conditional you like here: ID, template used, slug etc. // other identifiers would probably be better and won't rely on global $...
Gravity forms - Can I have multiple custom spinners?
wordpress
recently installed some debugging software on our server and realised that most errors are coming from realpath() in Wordpress sites. <code> realpath() [&lt;a href='function. realpath'&gt;function. realpath&lt;/a&gt;]: open_basedir restriction in effect. File(/var/www/vhosts/ xxx. com) is not within the allowed path(s)...
Looks like you are using one of the hacks to have the same wp-config.php file in development and deployment environments . AS it is noted at the end of that page, the hack were not tested in restricted environments like your. If you are not in development phase anymore then you should change your code in wp-config.php ...
Most Wordpress sites causing realpath errors
wordpress
I have a function which allows users to choose between pagination and next/previous links. In fact, I was provided the function on this site. I tested it today and it suddenly isn't working. I can't figure out the cause of this sudden interruption. It seems that the code will work if I choose the option I want, switch ...
Here is your problem: <code> "options" =&gt; array("Next/Previous Links", "Pagination"), "std" =&gt; "Next" </code> Your valid options don't match your default. Change this: <code> "std" =&gt; "Next" </code> ...to this: <code> "std" =&gt; "Next/Previous Links" </code> Then, in your function call, change this: <code> if...
Function Suddenly Stopped Working
wordpress
When i install this plugin (oQey gallery) i report some errors like: 1) Notice: Undefined index: type in \wp-content\plugins\oqey-gallery\gallcore.php on line 252 On line 252: <code> if($_GET['type'] == "oqeygallery"){ include ("insert_in_post.php"); } </code> 2) Notice: has_cap was called with an argument that is depr...
Undefined Index The first and third are the same problem: <code> if($_GET['type'] == "oqeygallery"){} </code> and <code> if(is_admin() &amp;&amp; ($_GET['page']=='oQeysettings'... </code> Basically are: if ( $_GET['foo'] == 'bar' ) The problme is that <code> $_GET['foo'] </code> is not set . That is, the <code> $_GET <...
Debugs/errors in oqey gallery
wordpress
Good Day. I am using a Wordpress theme and I want to add my own custom CSS. Now I have tried adding my own separate stylesheet after all the other php stylesheet calls in the header.php file. I tried editing the stylesheet in Appearance> Editor, and I even added !important to ALL my styles. But Wordspress keeps overwri...
Refer to the Codex entry for <code> wp_enqueue_style() </code> . Assuming you have a custom stylesheet, named <code> custom.css </code> , located in your Theme's root directory: <code> wp_enqueue_style( 'mytheme-custom', get_template_directory_uri() . '/custom.css' ); </code> You would put this in <code> functions.php ...
How do I register/enqueue a custom CSS file?
wordpress
Here's a standard function creating widget, it displays Widget's title and echoes "test" below it: <code> function widget( $args, $instance ) { extract( $args ); $title = apply_filters('widget_title', $instance['title'] ); echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; echo 'test'; echo ...
<code> wp_list_pages </code> does not wrap it's output in a <code> ul </code> or <code> ol </code> tag. That's up to you. In other words, if you just call <code> wp_list_pages </code> , it's going to spit out a bunch of <code> li </code> tags, which your browser assumes is wrong and "corrects" the html as it sees fit. ...
WordPress function breaks widget's markup?
wordpress
How can i change those editing inputs to title from caption? Some sources i found about new upload system: Using the WordPress 3.5 Media Uploader within plugins How to Add the WordPress 3.5 Media Manager Interface Basically looking for a proper solution like this: <code> // http://wordpress.org/support/topic/wp-35-any-...
I explained solution here: http://unsalkorkmaz.com/wp3-5-media-gallery-edit-modal-change-captions-to-title/ If you want just solution: <code> add_action( 'admin_footer-post-new.php', 'firmasite_replace_script_tmpl_attachment' ); add_action( 'admin_footer-post.php', 'firmasite_replace_script_tmpl_attachment' ); function...
Wp3.5 Media Gallery Edit modal: change captions to title
wordpress
I am trying to make a template that will be an html5/ vertical scrolling base. I have created an amount of page templates that each would represent a <code> &lt;section&gt; </code> on index.php which mainly all it does is to retrieve the child pages of a page I named <code> ROOT </code> using this: <code> // Set up the...
The snippet from codex is a bit redundant in your case. You can achieve what you need, by using snippets like these: index.php <code> $mainpage = get_page_by_title( 'ROOT' ); $the_query = new WP_Query( array( 'post_parent' =&gt; $mainpage-&gt;ID, 'post_type' =&gt; 'page', ) ); $index = 0; while ( $the_query-&gt;have_po...
Create a loop that gets pages with their template
wordpress
I just changed my WordPress website domain name (on the same server). Everything works fine, and the paths are correct. I can install plugins and updates without any problem. However, I can only upload media when the <code> wp-content </code> directory's permissions is set to 777. When I get it back to 755 I get an err...
Well' for anyone that faces this problem. look here: plesk-permissions-wordpress
Problem uploading files, after changing domain name
wordpress
You know when using <code> the_excerpt() </code> and no "excerpt" is set on a post it automatically uses the first 50 words or so. Is the same also possible when using <code> get_the_excerpt() </code> For instance I'm using <code> get_the_excerpt() </code> like this … <code> $return .= sprintf(' &lt;li&gt; &lt;div clas...
The function <code> the_excerpt() </code> is only a echo of the function <code> get_the_excerpt() </code> : <code> function the_excerpt() { echo apply_filters('the_excerpt', get_the_excerpt()); } </code> If you like a fall back for no input the excerpt meta box, then create a text from the content - <code> get_the_cont...
get_the_excerpt() with fallback like the_excerpt()
wordpress
I have made a Wordpress Plugin that is a kind of Download Manager. I have a external file download.php that is responsible for making downloads. This file is away of environment Wordpress, for this reason I must called: <code> $wp_root = dirname(dirname(dirname(dirname(__FILE__)))); require_once $wp_root.'/wp-load.php'...
To send HTTP headers just do it early enough. On the action <code> wp_loaded </code> for example. Don’t forget to call <code> exit; </code> when you are done, so WordPress doesn’t send its own headers later. See also stackexchange-url ("How to Rewrite Wordpress URL for a Plugin")
Wordpress repository forbids me call wp-load.php in non-WordPress file
wordpress
I'm building a table with items in it. What I don't understand is the following: When I type <code> &lt;td&gt; &lt;?php custom_get_terms('landschapspakket');?&gt; &lt;/td&gt; </code> , it echoes the value of <code> custom_get_terms('landschapspakket') </code> . What I want to do is use some conditional logic over it to...
Instead of doing: <code> print $term-&gt;name; </code> you need to <code> return $term-&gt;name; </code> so you can then use it for queries you could run on it.
PHP echoes value without the use of echo
wordpress
I did quite a bit of research but can't figure why this wouldn't work for me? <code> echo print_r($rel); // Array ( [0] =&gt; 63 [1] =&gt; 87 ) $args = array( 'post_type' =&gt; array( 'post' ), 'orderby' =&gt; 'ASC', 'post_in' =&gt; $rel ); $loop = new WP_Query( $args ); </code> I don't get any posts returned? Any idea...
You have to use <code> post__in </code> (double underscore) argument, instead of <code> post_in </code> : <code> echo print_r($rel); // Array ( [0] =&gt; 63 [1] =&gt; 87 ) $args = array( 'post_type' =&gt; array( 'post' ), 'orderby' =&gt; 'ASC', 'post__in' =&gt; $rel ); $loop = new WP_Query( $args ); </code> If you are ...
WP_Query: query posts by ids from array?
wordpress
I want users of my plugin to be able to define whether a task operates daily, twice daily, hourly or not at all as per the standard WP set-up. I'm storing these as 'daily', 'twicedaily', 'hourly' or '' in the option obr_scheduled_interval. The problem is that the task that I want 'obr_grab' runs every time there's a pa...
It looks to me that this line <code> add_action('obr_scheduled_task', array(&amp;$this, 'obr_activate_scheduled_task')); </code> should be <code> add_action('obr_scheduled_task', array(&amp;$this, 'obr_scheduled_task')); </code> otherwise you are re-scheduling on every page visit. Edit: Here is a logger that can be use...
Managing scheduled tasks
wordpress
If there are comments, I want to wrap the amount eg "5 comments" in the link to the comments section of the post, but when I add the echo for comments_link it errors. <code> &lt;?php comments_number( '', '&lt;span class="comment_meta"&gt;With:&lt;/span&gt; 1 Comment', '&lt;span class="comment_meta"&gt;With:&lt;/span&gt...
The problem is that you are echoing inside a string concatenation. Think of <code> echo </code> as something that will always begin on a new line. In most cases it's wisest to perform any calculations or string concatenations and store the result in a variable, and then call <code> echo $var; </code> on the following l...
How to output number of comments with link to comments
wordpress
I opened a similar topic, but since it is a little confusing, I decided to create a new topic to clarify more. i run the website and i found the errors seems like: <code> Notice: attribute_escape is deprecated since version 2.8! Use esc_attr() instead. in C:\xampp\htdocs\website\wp-includes\functions.php on line 2638 <...
Deprecation is... status applied to features, characteristics, or practices to indicate that they should be avoided, typically because they have been superseded. In other words, <code> attribute_escape </code> has been replaced by <code> esc_attr </code> . Any time you use a deprecated function WordPress triggers the e...
Replace the attribute_escape to esc_attr()
wordpress
Thesis appears to automatically add the sub-menus (sub-menu ul) to menu parents if childs exists. I have a specific need to remove this html from a particular menu. The menu name is: second_level Not sure if there a hook to do this. I'm trying to remove these from the menu name above. <code> &lt;ul class="sub-menu"&gt;...
You can change nav menu args via the <code> wp_nav_menu_args </code> filter. So let's say you have a theme that does something like this... <code> &lt;?php wp_nav_menu(array( 'theme_location' =&gt; 'second_level', 'depth' =&gt; 2, // how many levels to show // prolly some other stuff here )); </code> You can hook into ...
Removing Submenu from Menu
wordpress
I found an answered question here stackexchange-url ("Remove menus and submenus") 2 Answers for my problem but is there a way of changing the code a bit so that it removed the submenus for all Editor roles. not only for one user? and is there a way of improving this code? I am using 3.5.1 version of wordpress code that...
Replace all occurrences of <code> $current_user-&gt;user_login == 'username' </code> with <code> in_array('editor', $current_user-&gt;roles) </code> . And you can remove the call to <code> get_currentuserinfo(); </code> as for the user information is available from the global variable <code> $current_user </code> . Her...
Wordpress remove Submenus
wordpress
Since WP 3.5 (right?), the media manager has been "streamlined" and images are no longer, as I can see it, ordered by year / month in the media manager, although they are still saved as before. Is there any way I can use a hook (or something) to display folders in media manager?
The answer is obvious: no, you can't. Why? Because there is no folders in database for media attachments, all media files are stored as single row in <code> wp_posts </code> table. I suppose it does not really matter where your media files are stored, it could be your hosting or CDN network, somebody else hosting, etc ...
What happened to the media manger?
wordpress
I need to maintain pagination for use with infinite scroll. Is there no way to tell query_posts to retrieve sticky posts first? It seems to be default behaviour on a standard wordpress blog on the home page, but becomes a bit awkward on a custom template for a page from what I can tell. Thank you. Edited to show curren...
Digging through the source code I couldn't really find any weird logic that would cause 'category__in' to break the ordering of the results. If you do, you might as well file a bug in the WordPress Trac . It's also hard to reproduce this sort of issue, because it might depend on another issue which is specific to your ...
Ensuring sticky posts are retrieved first (without using two queries)?
wordpress
I have some logic in my code that's based on whether or not the user is logged in. How do I test it from my WP_UnitTestCase?
Call wp_set_current_user($id) to make a user ID the currently logged in user.
Can I simulate a user being logged in from a WP_UnitTestCase?
wordpress
I am displaying a div in the Edit Post screen using <code> add_meta_box() </code> . This function provides very limited positioning options via "priority" and "context" params and these are not sufficient for my needs. I need to be able to display the div below the Permalink but above the Insert Media button on Edit Po...
You cannot use a real metabox to do that, hook into <code> edit_form_after_title </code> instead. Here is a simple example: <code> add_action( 'edit_form_after_title', 'wpse_87478_pseudo_metabox' ); add_action( 'save_post', 'wpse_87478_save_metabox' ); function wpse_87478_pseudo_metabox() { global $post; $key = '_wpse_...
How do I position meta_box on post edit screen after the title?
wordpress
Some themes that I have seen such as the (famous) thesis or even a few other not so famous themes have just an index.php (which has nothing in it), functions.php (call's their framework) and a style.css - and of course the comments.php. These themes don't exactly show you where they are storing their css - obviously in...
You just need to make sure that you have all the necessary conditions handled properly. You can read more about the WordPress conditional tags available. As far as not having a <code> header.php </code> and a <code> footer.php </code> file in your currently active WordPress theme, you would just need to create an <code...
Some Themes do not have a header.php and footer.php how are they doing it?
wordpress
I had made a community with a different plugin (I think it was mingle. I recently installed buddypress, removed mingle and changed the site to suite. Now the problem is the existing users are not listed as members in the members page, only me, the admin. I have looked for, but not found, a solution. i am know how to us...
The following plugin will make all WordPress users to appear on BuddyPress members directory. It doesn't provide full migration of users, but it will update the <code> last_activity </code> user meta field that is used by BP to display users. This is a plugin code, so you need to create a new php file (eg. <code> bp-ad...
How to carry over existing wp users to a new buddypress installation
wordpress
I have created a page and added the following shortcode from wp-orbit-slider <code> [orbit-slider category="test"] </code> I want the contents of <code> [orbit-slider category="test"] </code> be displayed on the header part, instead of on the content area part, which the wordpress usually does . I tried adding the the ...
This might work for you, trying to hook early to <code> the_content </code> filter to strip the shortcode tag from it: <code> add_filter('the_content', 'ad_filter_the_content',1,1); function ad_filter_the_content($content) { // specify page id or array of page ids to include if (is_page(5)) { return str_replace('[orbit...
Adding short codes from a page's content on header and hiding the same from page's content
wordpress
this code here <code> &lt;div class="col"&gt; &lt;?php gab_dynamic_sidebar('Subnews1');?&gt; &lt;?php $postnr = of_get_option('of_wn_nr8') + of_get_option('of_wn_nr8a'); if (intval($postnr) &gt; 0 ) { ?&gt; &lt;span class="catname"&gt;&lt;a href="&lt;?php echo get_category_link(of_get_option('of_wn_cat8'));?&gt;"&gt;&l...
I created a fiddle for anyone that is interested HERE. Here is the javascript I used also to give the smooth scroll for an article container. <code> // clicking the links in the article link container $('#article-links a').click(function() { var $this = $(this); // save this instance of the click for access inside the ...
Showing All the Posts in the Loop
wordpress
While this is a question, it is as well a serious warning to publishers that separate their posts using <code> &lt;!--nextpage--&gt; </code> . Bare with me. I run a highly trafficked multiple author platform that rank very high on search engines. While making SEO related improvements, I noticed that only the first page...
The basic problem for a script solution is: <code> rel_canonical </code> does not offer any useful filter. So we have to replace that function: <code> remove_action( 'wp_head', 'rel_canonical' ); add_action( 'wp_head', 't5_canonical_subpages' ); </code> The next problem: <code> $GLOBALS['numpages'] </code> is empty bef...
Make Google index the entire post if it is separated into several pages
wordpress
At first I thought the task was trivial. I'd like to list the most recently added posts (say, 15 of them), but I am adding posts that are dated a few years back, yet I'd like them to show in the list, instead of just the ones that are dated the most recent. This is what I'm doing so far: <code> &lt;?php $args = array( ...
Try: <code> $postslist = get_posts( 'orderby=ID&amp;numberposts=15' ); </code> Here, we're ordering by the ID, which should relate to when the posts were added to the database.
List most recently added posts (with a twist)
wordpress
i'm using a query-loop on my template pages like this: <code> &lt;?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $wp_query = new WP_Query(); $wp_query-&gt;query('posts_per_page='.get_option('posts_per_page').'&amp;paged=' . $paged); global $wp_query; query_posts(array_merge($wp_query-&gt;query, ar...
If you merely want to modify <code> posts_per_page </code> for tag and category archive index pages, don't use <code> query_posts() </code> ; instead, filter the <code> $query </code> via <code> pre_get_posts </code> : <code> function wpse87489_filter_pre_get_posts( $query ) { if ( ( is_category() || is_tag() ) &amp;&a...
Pagination on category.php and tag.php not working
wordpress
From the codex, regarding filter hooks: <code> bloginfo_url applied to the the output of bloginfo("url"), bloginfo("directory") and bloginfo("home") before returning the information. </code> Is there a way I can specify that a bit more precise? So that I can hook something only to <code> bloginfo("url") </code> for exa...
You can access that, using the additional variable in the Filter Functions. The Filter <code> bloginfo_url </code> uses the <code> $show </code> parameter (the parameter you use when calling <code> bloginfo </code> ) and passes it to <code> apply_filters </code> . So hooking into <code> bloginfo_url </code> should be n...
Bloginfo hook - can it be more precise?
wordpress
This loop shows one featured post above 4 post titles from a certain category that is specified in the theme options. What I would like to do is show all 4 posts from the 4 titles, above the 4 titles. The 4 titles are from this snippet of code <code> &lt;a class="listtitle" href="&lt;?php the_permalink() ?&gt;" rel="bo...
Have you tried setting <code> $count </code> equal to 4 on line 8? Like this: <code> &lt;div class="col"&gt; &lt;?php gab_dynamic_sidebar('Subnews1');?&gt; &lt;?php $postnr = of_get_option('of_wn_nr8') + of_get_option('of_wn_nr8a'); if (intval($postnr) &gt; 0 ) { ?&gt; &lt;span class="catname"&gt;&lt;a href="&lt;?php e...
Modifying a Loop to Show More
wordpress
I've been asked to restyle the css of a WordPress website frontend. The website can't be in maintenance mode while working on it as it must stay up and running all the time. I assume that if I can add a small and unobtrusive condition in the header allowing the administrator to see a different css file than the users, ...
You should be able to simply check the capabilities of the currently logged in user. If they're an administrator the following example should do what you want it to. Just add this into your theme's functions.php file. Please note this code is untested, but it should get you where you want to be. If the level_10 capabil...
How to Display Frontend CSS for Administrator only
wordpress
I need help. I need to get a user ID or email (email is can do but ID is better) based on their phone number, outside of WordPress. I already have their phone number in a variable and billing_phone is custom metadata in the wp_users table. This is what I am using to load wp <code> `$parse_uri = explode( 'wp-content', $...
If you have <code> billing_phone </code> as user meta, which is the preferred way, that query would be incorrect. The advantage of utilizing custom user meta and adding a field for <code> billing_phone </code> would allow you to use <code> get_users() </code> . <code> $user = get_users('meta_key' =&gt; 'billing_phone',...
How do i get a specific user metadata using custom metavalue outside of wordpress?
wordpress
I have categories set up for car manufacturers. I have 4 custom taxonomies that are also set up: color, starburst, offer_type, and logo_count. Each post I upload to my wordpress has values for all 4 of those taxonomies and is assigned a category. I have a custom page template setup to display all posts that have the sa...
Found an answer to my own question. Still not sure how to implement it myself, but a plugin does this perfectly.
Getting taxonomies specific to categories
wordpress
I'm currently working on a plugin in which I would like to have a new setting (called 'show_introduction') that has the default value 'true'. I did this by the following which is hooked into 'admin_init' <code> register_setting('tf-song-list-settings-group', 'show_introduction'); if (get_option('show_introduction') == ...
Since you asked for my solution as an aswer, here it is. Firstly, as Chip Bennett pointed out, I had to re-arrange my whole approach to settings and options. As of now, I ended up using the following code: <code> class MYClass { function __construct() { add_action('admin_init', array($this, 'register_settings')); } fun...
How to use a newly registered setting with a checkbox and the default value 'true'
wordpress
How can I identify what category the current page is showing in the <code> &lt;head&gt; </code> ? Here's the code I have now: <code> &lt;?php if ( is_home() ) { ?&gt; &lt;!-- set up for home page ad --&gt; &lt;?php } elseif ( in_category( 'Restaurant Reviews' )) { ?&gt; &lt;!-- set up for restaurant reviews ad --&gt; &...
The <code> in_category( $category ) </code> conditional only returns true when the current post has the specified category assigned . If you want to determine when you are on a category archive index page , you should instead use <code> is_category( $category ) </code> : <code> if ( is_category( 'Restaurant Reviews' ) ...
How can I tell what category I'm in-- in the header?
wordpress
in <code> archive.php </code> file, I want to know, which type of archive I i'm in. For example, if I i'm in archive for category Personal I'd like to be able to display it in header of the archive. Of course, I can create file like <code> category-12.php </code> , <code> category-13.php </code> ... and then harcode it...
Inspect <code> get_queried_object() </code> . On an archive for the category <code> Uncategorized </code> you get something like … <code> stdClass Object ( [term_id] =&gt; 1 [name] =&gt; Uncategorized [slug] =&gt; uncategorized [term_group] =&gt; 0 [term_taxonomy_id] =&gt; 1 [taxonomy] =&gt; category [description] =&gt...
Find out in which kind of archive am I
wordpress
I'm trying to create two (for now) sites in multisite WP installation that use same theme, but require somewhat different functionality i.e homepage has a bit different layout and there will be some CSS changes. Is there a way that I could use to override functions.php and other theme files for each site?
I would recommend a Parent/Child theme for this. Read the section linked below for a good example of making functions within your theme pluggable. http://codex.wordpress.org/Child_Themes#Using_functions.php
Different functions file for each site in multisite installation?
wordpress
I implemented a custom post type for a class post. Now every post has a additional date picker called "date_event", my question is: Any have ideas how can i order the post for the last date of the label date_event? Thank you for your help.
This comes directly from the ACF documentation : <code> /* * Order Posts based on Date Picker value * this example expects the value to be saved in the format: yymmdd (JS) = Ymd (PHP) */ $posts = get_posts(array( 'meta_key' =&gt; 'custom_order', // name of custom field 'orderby' =&gt; 'meta_value_num', 'order' =&gt; 'A...
Order post by date with ACF
wordpress
Is it possible to use the permalink structure defined in the Wordpress settings panel for custom post types? And if so, how do I do that? I currently have: <code> function add_posts_two() { $labels = array( 'name' =&gt; 'Poststwo', 'singular_name' =&gt; 'posttwo', 'add_new' =&gt; __('New Posttwo'), 'add_new_item' =&gt;...
Try changing: <code> 'rewrite' =&gt; false, </code> in $args array to: <code> 'rewrite' =&gt; array( 'slug' =&gt; 'posttwo', 'with_front' =&gt; false, 'pages' =&gt; false ), </code> It should do the trick If I understood Your question correctly.
custom post type default permalink
wordpress
I have two categories that will always stay the same. They are called "Events" and "Show on frontpage". The latter is a child category to Events. What i want to do is, when fetching posts (using WP_Query), check if the post is in the Events category. If it is, and it is NOT in the "Show on frontpage" category, don't fe...
Here we go, try a tax_query instead http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters <code> ... 'tax_query' =&gt; array( 'relation' =&gt; 'OR', array( 'taxonomy' =&gt; 'category', 'field' =&gt; 'slug', 'terms' =&gt; array( 'event','show_on_front' ), 'operator' =&gt; 'AND', ), array( 'taxonomy' =&...
WP_Query: Fetch posts that are in (category1 and not in category2), OR posts that are not in cagegory1
wordpress
i use the code to view subcategory on category page <code> &lt;?php if(is_category()) { $breakpoint = 0; $thiscat = get_term( get_query_var('cat') , 'category' ); $subcategories = get_terms( 'category' , 'parent='.get_query_var('cat') ); $items=''; if(!empty($subcategories)) { foreach($subcategories as $subcat) { if($t...
Yea a bit unclear but I think I understand what your trying to achieve. It's displaying that like most likely due to css. You could target it with a CSS3 pseudo-selector <code> .sidebar a { float: left; } .sidebar a:nth-child(4n-0) { clear: left; } </code> OR.. this might work, no promises though because I can't see yo...
how can view all three subcategory in same line(found ex: and code)
wordpress
I have a metabox with an array of input: <code> &lt;input type="text" name="activite_dates[]" size="30" /&gt;&lt;br /&gt; &lt;input type="text" name="activite_dates[]" size="30" /&gt;&lt;br /&gt; &lt;input type="text" name="activite_dates[]" size="30" /&gt;&lt;br /&gt; ... </code> And i'm saving it like this <code> upd...
<code> &lt;?php // Check to make sure array is ready if( isset($_POST['activite_dates']) &amp;&amp; is_array($_POST['activite_dates']) ) { // If we have an array ready to save delete all the previous data delete_post_meta( $post_id, "dates"); foreach($_POST['activite_dates'] as $date) { // Use add post meta instead of ...
Multiplicate entry on update_post_meta
wordpress
I am using the fetch_feed() function provided in WordPress to build a SimplePie feed object. The code from WP is the following: <code> function fetch_feed($url) { require_once (ABSPATH . WPINC . '/class-feed.php'); $feed = new SimplePie(); $feed-&gt;set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' ); // We must manuall...
SimplePie in WordPress uses the built-in kses sanitization, rather than SimplePie's. Instead, you can filter on <code> wp_kses_allowed_html </code> and add your elements there. Keep in mind that this will occur for all post santization, not just via SimplePie. <code> function se87359_add_allowed_tags($tags) { $tags['my...
WordPress SimplePie modifications
wordpress
I'm creating a simple shortcode function and need to specify a list of IDs as a variable. I've checked the Codex but I'm not sure how this is handled. The shortcode is: <code> [video_vote users="13027,13023,12583"] </code> Is the best way to loop through them by using a split or explode on the comma or is there a WordP...
<code> explode </code> will be your best option. WordPress has a few built in functions to handle arrays of function arguments ( <code> wp_parse_args </code> and <code> shortcode_atts </code> for example), but nothing relating to splitting a string and iterating the result. It's not entierly clear to me what you are tr...
Shortcodes and a list of IDs?
wordpress
I have a website setup made up of with more than 3-4 WordPress setups as subdirectories of main. For example: <code> Site | ---------- Site/Site1 | ---------- Site/Site2 | ---------- Site/Site3 </code> Each have separate codebase, separate DB for itself. The Database server is one and the host directory is also one. Ba...
In the name of bad practices, I'm going to advise that you immediately rule out these using raw SQL queries with remote databases in the same page. It would be slow, insecure, and a hassle to maintain. That you've landed yourself in a predicament where a combination of hyperDB+multisite is not an option demonstrates th...
Doing a loop with multiple DBs simultaneoulsy
wordpress
Media Manager once again. This time I'm looking for a simple hack/hook/filter to change default "Attachment Display Settings" from media manager. The option is "Link To" that is default set to "Media File" and I would like to force it for all users to be default set to "none". If there is no way to do it with hook/filt...
You can do what you want by overriding appropriate Backbone view, which is responsible for rendering attachments display settings form. plugin.php <code> add_action( 'load-post.php', 'wpse8170_media_popup_init' ); add_action( 'load-post-new.php', 'wpse8170_media_popup_init' ); function wpse8170_media_popup_init() { wp_...
Wordpress Media Manager 3.5 - default link to
wordpress
I'm using the following code to generate some pagination: <code> $wp_query = new WP_Query(); $wp_query-&gt;query('posts_per_page=5'.'&amp;paged='.$paged); $big = 999999999; echo '&lt;div class="pagination"&gt;'; echo paginate_links(array( 'base' =&gt; '%_%', 'format' =&gt; str_replace($big, '%#%', esc_url(get_pagenum_l...
Short answer: Try <code> 'base' =&gt; str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' =&gt; '?paged=%#%', </code> Long answer: I took a look at the <code> paginate_links() </code> source code ( v3.5.1 ) and there is this line ( # ) <code> $link = str_replace('%_%', 1 == $n ? '' : $format, $bas...
Strange paginate_links behavior. First page link is always whatever page I'm on, all other links are correct
wordpress
how would one go about redirect certain pages if the user viewing them is logged into the WordPress CMS? For example, we have 2 registration pages that when logged in should direct to some other page / category archive. Thanks.
$location = The absolute URI to which the user will be redirected. No default. $status = The status code to use. For example, 301, 302, etc. The default is 302. You can use template tags for the $location parameter, for example: <code> &lt;?php // redirect to the home page wp_redirect(home_url()); exit; ?&gt; &lt;?php ...
Redirect certain pages if user logged in
wordpress
I'm using the Annual Archive plugin which shows the year in the sidebar. I want to display in the dropdown only the years that have posts in category 17. How can i achive this? My code is below... <code> function widget( $args, $instance ) { extract($args); //$c = $instance['count'] ? '1' : '0'; //$d = $instance['dropd...
Try this, you need to use two filters "getarchives_where" and "getarchives_join" to alter the way archive are shown and include your category 17.. <code> function widget( $args, $instance ) { extract($args); //$c = $instance['count'] ? '1' : '0'; //$d = $instance['dropdown'] ? '1' : '0'; $format = empty($instance['form...
Customing Annual Archive plugin
wordpress
I have a certain condition in my code (if the user is visiting the page from a network range) and I can ask for this condition easily, let's say: <code> if ( $user_in_allowed_range) </code> What I want is to offer the registration button only to users who fulfill this condition, and other users should still be able to ...
Since <code> get_option('users_can_register') </code> will return the setting value for the "Anyone can register" setting used for displaying the registration link, you could probably add a <code> get_option </code> filter overriding the value for the <code> users_can_register </code> key. In this case i even think the...
Disable registration on certain condition
wordpress
thanks for reading. I'd like to take total control of how the registrations are done on my new site. I want the new user to write his own password, and fill different fields. Display my own errors and messages, etc.. Can you point me in the right direction? All I'm finding are plugins that use short codes, that aren't ...
Using Giri's function and information from this link http://codex.wordpress.org/Customizing_the_Registration_Form I managed to end up with the following function to create a Custom Registration for my WordPress site. The user chooses his own password, also specifies Name and Last Names. Username equals e-mail, since I ...
Register form how to get Total Control of it
wordpress
I have a site being developed locally and I want to import the contents to an online installation. I used wordpress "import" but it cant get the media files. Is there any "wordpress" was of doing this or will I have to get access to my LDE from outside or upload the entire installation which I would rather avoid?
When I use WordPress Import in this cases, this is what I do: Export the XML in localhost. Open the exported file in a text editor. Search and replace <code> http://localhost/wp-content/uploads/ </code> for <code> http://example.com/custom-temporary-folder/ </code> . Upload the <code> uploads </code> folder via FTP to ...
Import media to online WordPress from local development
wordpress
I use one of smthemes and there is this code in theme to show related post. it shows the last created related posts, but I want to show related post by random, How can I do that? <code> global $SMTheme; if ($SMTheme-&gt;get( 'layout', 'related' )) { ?&gt; &lt;div class="related-posts"&gt; &lt;h3&gt;&lt;?php echo $SMThe...
In the arguments for <code> get_posts </code> , add <code> 'orderby' =&gt; 'rand' </code> . See <code> get_posts </code> in Codex for a full list of available arguments. <code> $args = array( 'category__in' =&gt; $category_ids, 'post__not_in' =&gt; $showed_posts, 'showposts' =&gt; $SMTheme-&gt;get( 'layout', 'relatedcn...
Display Related Posts by Category in Random
wordpress
On my blog, the Pinterest button creates a small gap underneath the footer. Looking at the code, the cause is the iFrame that the Pinterest javascript embeds in the page. It looks like this: <code> &lt;iframe src="//assets.pinterest.com/pidget.html?r=862117.4577227819#via=http%3A%2F%2Flocalhost%3A8888%2Finternet-securi...
You can select every iframe, just by writing: <code> iframe{display:none} </code> If you have multiple iframes, and this is the only one you want to apply this styling to, you can write something like this: <code> iframe[src^="//assets.pinterest.com/pidget.html"]{display:none} </code> Note: Not really a WordPress quest...
How can I style an IFRAME element that has a constantly changing class name?
wordpress
Hi this is more of a solution and advice question. I want to search my wordpress site and load the search results in a very typical way (unordered list with title, image and excerpt). Upon clicking the title of each post I want to load the post itself in a div directly in a new panel on the right. I want the search res...
Since you wanted best-practices, methods, advice, here is my take on how you should proceed: First of all, divide the content of your page in two ideal spaces , the list of posts, and the content. Something like this: <code> &lt;nav class="post-navigation"&gt; &lt;ul&gt; &lt;li&gt; &lt;h2&gt;{Post title}&lt;/h2&gt; &lt...
Search results load individual post in slide out div
wordpress
I am trying to put different body background-image for each category. <code> body { background-color: #000; background-image: url(img/bg.png); background-repeat: no-repeat; background-position: center top; font-size: 14px; color: #555; font-family: Arial, Helvetica, Verdana, sans-serif; } </code> I only want different ...
You can do this using Wordpress's handy <code> body_class() </code> function. Depending on whether and how it is used in your theme, it may already be giving you what you need. Here's how to find out: Check the source of your page to see if the <code> &lt;body&gt; </code> tag in your category archive pages has any clas...
Different background-image by category
wordpress
I'm working on a new site for a charity. They publish a printed magazine &amp; we would like the website to always reflect the current issue of the magazine. So far I have a front page (home page) with excerpts from 3 most recent lead articles (wp posts). For layout purposes, the articles are categorized as frontpage-l...
I'd say go with categories: it seems your categories are already being used for 'back-end' purposes, so I'd imagine they're already hidden from the front-end users. Otherwise, go for a custom taxonomy (something like 'issue' taxonomy perhaps), which is a bit more work, but gives you a lot more control. Take a look at t...
Cache previous versions of website?
wordpress
Using <code> wp_nav_menu() </code> , how can I append a value at end of each URL? For example, I have the following url: <code> http://www.example.com/ </code> but I have to append a language parameter at the end, so the url should be: <code> http://www.example.com/?lang=$language </code>
I found the solution modifying the behaviour of <code> wp_nav_menu </code> with the <code> wp_get_nav_menu_items-filter </code> . Here's a somewhat complete example: <code> class ModifyLinkFilter { protected $_prio = 10; protected $_args; public function __construct($addargs = array(), $prio = 10) { $this-&gt;_args = $...
WP Nav menu append to url
wordpress
I am using Add From Server plugin http://wordpress.org/extend/plugins/add-from-server/ basically it imports/upload image from the server. Currently the plugin copies the images into month/year folder format but I want to change it by making it copy by the Post ID folder format instead of month/year. I have already trie...
You can try to add this into your <code> functions.php </code> file: <code> add_filter( 'upload_dir','wpse87234_upload_dir'); function wpse87234_upload_dir($uploads){ // check if we are in the "Add From Server" media tab if (isset($_REQUEST['post_id']) &amp;&amp; isset($_GET['tab']) &amp;&amp; $_GET['tab']=="server") {...
Using Add from Server to upload by post ID
wordpress
I am curious how WordPress know that if I have a category.php and do the basic loop inside there that when I click on category A I get all of A's posts. The reason I ask, is because I have seen themes that just have an index.php and when you click on Category A in those themes you get all of A's posts, and they do not ...
If you look at the template hierarchy for categories you will see it follows: category-{slug}.php category-{id}.php category.php archive.php index.php As Milo says these templates are just using the loop to display what is already queried, so there template itself does not matter outside load order of the hierarchy.
wordpress loop and template files
wordpress
I'm writing my first WordPress theme and have a question about the use of The Loop in page templates. The page templates I've looked at all follow basically the same pattern (example from Twenty Twelve): <code> &lt;?php while ( have_posts() ) : the_post(); ?&gt; &lt;?php get_template_part( 'content', 'page' ); ?&gt; &l...
According to the Theme Guide , full loops should be used, even on single templates. Full loops must be used in all templates. Just calling <code> the_post() </code> in a template like <code> single.php </code> or <code> page.php </code> is not enough. So yes, it's a best practice to use full loops.
Do I need to use The Loop on pages?
wordpress
Hi I'm trying to pull posts using the wp query. Just one problem--I am trying to sort the posts alphabetically by a certain meta_value. Thing is that this meta_value is a serialized array. Is there an easy way to do this without having to unserialize it? Thanks! <code> a:1:{i:0;a:1:{s:7:"people";s:16:"Tanya Garca";}} <...
Is there an easy way to do this without having to unserialize it? Not in any reliable way. You can certainly <code> ORDER BY </code> that value but the sorting will use the whole serialized string, which will give you technically accurate results but not the results you want. You can't extract part of the string for so...
order by meta_value serialized array
wordpress
I'm working on this function of WordPress. <code> function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) { $id = intval( $id ); $_post = get_post( $id ); if ( empty( $_post ) || ( 'attachment' != $_post-&gt;post_type ) || ! $url = wp_get_attachment_url( $_post-...
You have to supply a argument count when adding the filter callback, and add the arguments you are expecting to receive to your callback function. Looking at the <code> wp_get_attachment_link </code> source you can tell that 6 arguments is supplied when applying the filters (the link markup and <code> $id, $size, $perm...
Insert custom ID into wp_get_attachment_link
wordpress
I'm developing a website using WordPress and I need to make a totally customized theme. Everything seem to work well until I found something wrong at search result which doesn't match with customer requirements. I have no experience with PHP and WordPress. So let me ask two questions. How can I validate the WordPress S...
What you tried to use is broken. <code> add_filter( 'pre_get_posts', 'modified_pre_get_posts' ); function modified_pre_get_posts( WP_Query $query ) { if ( $query-&gt;is_search() ) { $query-&gt;set( 'post_type', array( 'page-home' ) ); } return $query; } </code> That function definition is not valid. You would have seen...
How to control WordPress Search Behavior?
wordpress
I'm using a theme which works with Genesis Framework. The theme is called pinsomo &amp; I'm wondering how to "move" comments count div to the bottom of the post. Here is the demo: [[link has expired]] You see the comment icon next to the title. I want to move it to the heart icon.
You can use the genesis_post_info and genesis_post_meta filters in your child theme rather than modify the parent theme frameworks files which will be lost when you update Genesis. Remove comments link from post info <code> add_filter( 'genesis_post_info', 'remove_post_info_comments_link' ); function remove_post_info_c...
Genesis Child Theme Modifying Comments display
wordpress
This is default wordpress add_editor_style function: <code> function add_editor_style( $stylesheet = 'editor-style.css' ) { add_theme_support( 'editor-style' ); if ( ! is_admin() ) return; global $editor_styles; $editor_styles = (array) $editor_styles; $stylesheet = (array) $stylesheet; if ( is_rtl() ) { $rtl_styleshee...
Here is my solution: <code> add_filter('the_editor_content', "firmasite_tinymce_style"); function firmasite_tinymce_style($content) { add_editor_style('assets/css/custom.css'); // This is for front-end tinymce customization if ( ! is_admin() ) { global $editor_styles; $editor_styles = (array) $editor_styles; $styleshee...
add_editor_style is not loading in frontend. Any solution?
wordpress
I did a custom post query for AIO Events Calendar, as described here: stackexchange-url ("All in One Calendar Plugin Custom Post Type Query") But it doesnt work. <code> &lt;?php echo esc_html( $event-&gt;cost ) ?&gt; </code> returns the cost, but <code> &lt;?php echo $contact ?&gt; </code> and any other variable withou...
Anything that comes out of this query-- <code> $event = Ai1ec_Events_Helper::get_event($post-&gt;ID); </code> -- will need the <code> $event-&gt; </code> part. That is how you access data from an object. That is just pure PHP. I don't know why some of the values stackexchange-url ("in that answer"), like <code> $contac...
All in one calendar custom post type query doesnt work as expected
wordpress
I have a contact form previously used in static websites that I’d like to adapt to use in WordPress. I realize there are numerous plug-ins such as Contact Form 7, but would rather use this since it’s simple and I’m familiar with it. Basically, on submission the form page goes to a second PHP page for the post action, r...
I would like to recommend you to read The Rewrite API: The Basics article. Especially pay attention to the <code> Add Custom Endpoint </code> section where you can find how to create what you need.
Form action URL unrecognized
wordpress
I am creating a plugin that needs to output things on the front end of the site. I tried keeping the default look as clean as possible, but I'd also like to make it easy for the users to modify. My thinking is to include the ability to load a custom stylesheet instead of the default one, if the user creates a styleshee...
Make as simple as possible for theme developers. Most are not programmers. Two very simple options: add_theme_support() and get_theme_support() Provide an identifier and some options. Let's say your identifier is <code> drtanz_plugin </code> . A theme author could now add the following to her theme’s <code> functions.p...
Right approach for plugin output styling/template
wordpress
I purchased a theme that I want to change a bit. I'm familiar with writing some if/else statements but not this type and not matter what I do, I can't add an else/if without breaking the code. Below is the code from the theme... <code> &lt;?php if (!is_404() &amp;&amp; !is_attachment()) { if (is_singular() || is_page('...
The conditional for posts is <code> is_single() </code> . So … <code> if ( ! is_404() &amp;&amp; ! is_attachment() &amp;&amp; ! is_single() ) { # rest of the code } </code>
Adding else if conditional statement to purchased theme
wordpress
I am using wordpress twentytweleve template and I notice every time I upload an image it creates 3 different thumbnail sizes. In my media settings I have already set medium &amp; large size to 0. It seems like when I use this theme it will create the 3 different thumbnail sizes but if I use my own custom theme it doesn...
Create child theme for Twenty Twelve and add code in stackexchange-url ("How to disable multiple thumbnail generation?") to functions.php
Prevent creating multiple image resizes in twentytwelve template
wordpress
I'm filtering the main query of Jigoshop with my own taxonomy with this hook ( The file responsible for Jigoshop queries that I'm hooking, Jigoshop hooks onto WP 'request' filter ): <code> add_filter( 'loop_shop_tax_query', 'my_loop_shop_tax_query', 11 ); function loop_shop_tax_query( $request ) { $region = 'dublin'; i...
The simplest way is, in all honesty, to hook into <code> wp_title </code> and change things, and just be aware that the warnings are there but not showing in production (because you've property configured your server). What follows is a kind of hacky solution. If you take a look at <code> get_queried_object </code> ......
How to query a custom post type with a taxonomy filter but display post type archive page?
wordpress
I want to use checkboxes on registration form, but values are not storing in the profile page. here is the code on functions.php <code> &lt;?php add_action( 'show_user_profile', 'my_show_extra_profile_fields' ); add_action( 'edit_user_profile', 'my_show_extra_profile_fields' ); function my_show_extra_profile_fields( $u...
Short of creating a stackexchange-url ("custom registration page"), there are not much hooks that can be used to add custom fields to the default form. I tried once (with <code> register_form </code> hook) and only default fields (description, website, etc) were successfully recognized and saved. Found this Q&amp;A tha...
Checkboxes in registration form
wordpress
I'm thinking it's just a PHP code error, but for some reason the following code won't work, it just keeps giving me Internal Server Error 500 <code> &lt;?php $ajfl_adLuck = rand(1,3); if ($ajfl_adLuck == 2) { echo "&lt;div id=\"sidebar-awesome-container\"&gt;"; echo "&lt;div id=\"sidebar-awesome-wrapper\"&gt;"; echo "&...
<code> echo "&lt;img src=\"" . bloginfo('template_url'); . "/img/sample-ad-side.png\" alt=\"Sample Advertisement\"&gt;"; </code> You added a semicolon, what comes after that semicolon is a new statement. <code> . "img/ </code> etc is not valid PHP, so it errors out. Also bloginfo does not return its value, it prints it...
Trying to display ads on only a third of posts in a loop. Keep getting Error 500?
wordpress
I'm new to wordpress and programming in general. For my first site there is a custom template in which I want to load a javascript library. After registering and enqueueing it in functions.php my site no longer loads properly. I'm sure what it is simple mistake and would really appreciate a little help. For the record,...
First, be sure to enable <code> WP_DEBUG </code> in your <code> wp-config.php </code> file, so that you can see fatal error messages. In this case, the problem is that you've named your function <code> load_wforms() </code> , but you reference the callback <code> wforms </code> in your <code> add_action() </code> call:...
Why is this function crashing my wordpress installation?
wordpress
I know the many tricks to see if said theme is activated, I have scoured the internet. I am not looking for re-pasting of that code. What I am looking for though is weather or not 3.3-3.5 released a new function that does something upon theme_init, I saw some sort of hook, but I can't remember where, in the codex, deal...
You might be looking for the <code> after_setup_theme </code> hook: http://codex.wordpress.org/Plugin_API/Action_Reference/after_setup_theme
WordPress Theme activation hook?
wordpress
Okay, let's say I have a website with the following navigation: HOME - ABOUT - PRODUCT - NEWS - CONTACT The 'about' and 'contact' page are just simple pages of course. The 'product' page is just an archive of a custom post type. Nothing special over there. Then there's just the 'home' and 'news' page. If I make a page ...
So question is, do you really need to create an empty page just to set that page as the posts page/blog page? Yes, you do. If you use a static front page, and want to have a page for (blog) posts, then you need to create a separate static page, and assign it as "page for posts" in <code> Settings -&gt; Reading </code> ...
Do I need an empty page for a different blog page?
wordpress
I'm trying to create a Wordpress theme, and I'm having a little difficulty with creating an easily accessible archives page. First off, I'm not referring just to the standard archive.php in the template hierarchy. What I'm trying to do is make a separate page on the site that lists all posts (not sorted by tag/category...
What I'm trying to do is make a separate page on the site that lists all posts (not sorted by tag/category/year) in a single, easily-accessible portion of the site by just going to /archive (e.g. www.example.com/archive) The correct approach is, indeed, to create a custom page template , so that the user can create a s...
Create /archive page in Wordpress Theme
wordpress
Hi if I change the category slug of one of my categories, does WordPress automatically handle redirects from the old category slug to the new one?
No, WordPress only handles changes of individual post slugs, by saving old slugs in post meta. You could try a plugin, like Redirection , to handle old category slug 301 redirects.
Change Category Slug Redirection
wordpress
After reading through here and trying various options, I am finally able to get my custom post types 'testimonial' (created with product 'Toolset') to show along with my standard cat/tag queries WITHOUT the menu disappearing!! Here is the code I came up with, and placed in my theme's custom-functions.php file: <code> a...
<code> pre_get_posts </code> runs on every query, so you want to check if <code> is_main_query() </code> so it only applies to the default query and not additional queries you run on the page. You should also get in the habit of referencing the query object passed to the function like <code> $query-&gt;is_category() </...
Query reset problem or flawed code to enable custom post type query
wordpress
I want to make a crop on the images of my blog page that have more than 443px adjust it to 645x443 size, exactly. I used this code: <code> add_theme_support ('post-thumbnails'); add_image_size ('blog-page', 645, 445, true); </code> However, the image is resized instead of making the crop. Exemples: Original image: http...
From this comment: Sry, i forgot it, but i want size of 645x445, exactly, and that image dont have it. The width of it is 588px. Look: img201.imageshack.us/img201/4728/40405258.png Wordpress need make a zoom on it. WordPress does not zoom. It only crops. If you want an image to have a custom intermediate size, then you...
Add_image_size not cropping
wordpress
On the front-end, I'm using a query to show all attachments attached to the current post. However, on the compose page, there's no way for a user to see how many images are attached without opening up the media gallery. I would like to add a meta box (or something) to display the current number of attached images – per...
<code> add_action( 'add_meta_boxes', 'attached_images_meta' ); function attached_images_meta() { $screens = array( 'post', 'page' ); //add more in here as you see fit foreach ($screens as $screen) { add_meta_box( 'attached_images_meta_box', //this is the id of the box 'Attached Images', //this is the title 'attached_im...
Show how many images are attached to a post/page on compose page
wordpress