vendredi 27 mars 2015

Conditional statements in wordpress themes


I have the following code at the start of my single.php loop that displays the post featured image as a background.



<?php $featured_background = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' ); ?>

<div class="parallax" id="parallax1" style="background: url(<?php echo $featured_background['0'];?>) !important; background-position: 50% 50% !important; background-repeat: no-repeat !important; background-size: cover !important; background-attachment: fixed !important;" data-stellar-background-ratio=".5">
<div class="parallax-content">
Some content
</div>
</div>


I've set .parallax to be 600px high in the stylesheet.


Of course this poses a problem for posts that don't have a featured image.


It seems then that I need a conditional statement that only displays the code above if the post has a thumbnail.


I've looked at the wordpress codex, but am unsure how to apply the teachings there to my case. It also looks like they'd be a lot of use of the echo command due to all the HTML.


I think I understand the first part of the statement which will be something like:



<?php

if ( has_post_thumbnail() ) {
echo'my html code as above'
}
else {
just get on with rendering the rest of the page
}
?>


But then I don't understand how to tell it to just get on with rendering the page in the else statement.





String taken from database table post_meta is showing HTML tags on Frontend


I have saved a string in post_meta table in wordpress database with html entities like-


<p>Hello <b>Shashank</b>, I have an idea.</p>


When I get this string on frontend using function


get_post_meta(get_the_id(),field_name, true).


It echoes string with HTML entities as same as it stores in DB.


But I want to show this sting as "Hello Shashank, I have an idea."


How can I do this.?





Submit a form without keyboard input, addition with the help of button


I am new to WordPress. I want to create sales status website, something like this...


< - button>Item 1< + button> < - button>Item 2< + button> < - button>Item 3< + button> < - button>Item 4< + button> I want a plus and minus button to add the number of a particular item.


For example if I sold (item 1) 4 times, I will click it 4 times and the number will show at the bottom.


Do I need to use a form plugin for this





I can't use nth-child on pair divs


i'm trying put pair divs with float:right but don't work. Only work with li???


I need put < div class="portfolio-entry-media" > only pairs (2, 4, 6...) with float right. Is this possible? thanks!


this is the code



<div class="wpex-row vcex-portfolio-grid clr left-thumbs" data-transition-duration="0.0">

<div class="post-359 portfolio type-portfolio status-publish has-post-thumbnail hentry portfolio-entry span_1_of_1 col col-1 cat-38">



<div class="portfolio-entry-media">


<img src="http://ift.tt/1yiI4zD" width="222" height="167" class="portfolio-entry-img" alt="Bótox">



</div><!-- .portfolio-entry-media -->




<div class="portfolio-entry-details clr">



<h2 class="portfolio-entry-title entry-title">


<a href="http://ift.tt/1MbaiYA" title="Bótox">
Bótox </a>


</h2>




<div class="portfolio-entry-excerpt clr">
<p>Maecenas nec ultrices massa. Quisque orci diam, malesuada id augue nec, faucibus interdum dolor. Curabitur sagittis, felis porttitor placerat rhoncus, mauris diam sollicitudin nisl, sed luctus nulla sem non velit. Fusce a libero ullamcorper, volutpat orci ut, suscipit erat. Morbi tempor tortor vel urna lobortis. Hendrerit faucibus massa consequat. Vivamus feugiat sapien massa, non luctus purus scelerisque et. Donec sodales pellentesque diam, et adipiscing erat imperdiet ac. Integer a lacinia velit. Pellentesque eu adipiscing arcu, a eleifend nulla. Vivamus tempus sem erat, eget lobortis odio interdum at. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus et feugiat risus. Ut a egestas libero. Morbi dictum quis felis vel congue. Sed eu arcu auctor, volutpat justo et, egestas libero. Phasellus sagittis sem in iaculis faucibus. Aenean vel lacus purus.</p>
</div><!-- .portfolio-entry-excerpt -->




</div><!-- .portfolio-entry-details -->


</div><!-- .portfolio-entry -->



<div class="post-265 portfolio type-portfolio status-publish has-post-thumbnail hentry portfolio-entry span_1_of_1 col col-1 cat-38">



<div class="portfolio-entry-media">


<img src="http://ift.tt/1Mbagjr" width="222" height="167" class="portfolio-entry-img" alt="Ácido Hialurónico">



</div><!-- .portfolio-entry-media -->




<div class="portfolio-entry-details clr">



<h2 class="portfolio-entry-title entry-title">


<a href="http://ift.tt/1yiI4zG" title="Ácido Hialurónico">
Ácido Hialurónico </a>


</h2>




<div class="portfolio-entry-excerpt clr">
<p>Donec sed vulputate nunc, at fringilla purus. Nulla molestie ut turpis sit amet suscipit. Nullam vulputate diam elit, ac varius turpis vestibulum aliquet. Vestibulum mattis purus et blandit hendrerit. Nulla luctus nisi et pellentesque aliquam. Morbi orci massa, vestibulum vel urna quis, porta interdum libero. Vivamus id eros congue, lacinia elit eget, condimentum risus. </p>
</div><!-- .portfolio-entry-excerpt -->




</div><!-- .portfolio-entry-details -->


</div><!-- .portfolio-entry -->



<div class="post-342 portfolio type-portfolio status-publish has-post-thumbnail hentry portfolio-entry span_1_of_1 col col-1 cat-38">



<div class="portfolio-entry-media">


<img src="http://ift.tt/1MbaiYD" width="222" height="167" class="portfolio-entry-img" alt="Mesoterapia">



</div><!-- .portfolio-entry-media -->




<div class="portfolio-entry-details clr">



<h2 class="portfolio-entry-title entry-title">


<a href="http://ift.tt/1yiI3f9" title="Mesoterapia">
Mesoterapia </a>


</h2>




<div class="portfolio-entry-excerpt clr">
<p>Integer semper malesuada elit. Donec consequat nulla nunc. Praesent nisi ipsum, imperdiet et venenatis et, sagittis nec mi. Phasellus luctus diam elit. Integer porta adipiscing felis ultrices viverra. Morbi tempor tortor vel urna lobortis. Hendrerit faucibus massa consequat. Vivamus feugiat sapien massa, non luctus purus scelerisque et. Donec sodales pellentesque diam, et adipiscing erat imperdiet ac. Integer a lacinia velit. Pellentesque eu adipiscing arcu, a eleifend nulla. Vivamus tempus sem erat, eget lobortis odio interdum at. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus et feugiat risus. Ut a egestas libero. Morbi dictum quis felis vel congue. Sed eu arcu auctor, volutpat justo et, egestas libero. Phasellus sagittis sem in iaculis faucibus. Aenean vel lacus purus.</p>
</div><!-- .portfolio-entry-excerpt -->




</div><!-- .portfolio-entry-details -->


</div><!-- .portfolio-entry -->



<div class="post-324 portfolio type-portfolio status-publish has-post-thumbnail hentry portfolio-entry span_1_of_1 col col-1 cat-38">



<div class="portfolio-entry-media">


<img src="http://ift.tt/1MbaiYG" width="222" height="167" class="portfolio-entry-img" alt="Hilos Tensores">



</div><!-- .portfolio-entry-media -->




<div class="portfolio-entry-details clr">



<h2 class="portfolio-entry-title entry-title">


<a href="http://ift.tt/1Mbagjx" title="Hilos Tensores">
Hilos Tensores </a>


</h2>




<div class="portfolio-entry-excerpt clr">
<p>Curabitur metus lectus, condimentum eu lacinia sed, aliquam et nibh. Nullam et mi eu ipsum accumsan vestibulum. Donec dignissim, nibh vel consequat molestie, lacus felis suscipit velit, sit amet mollis mauris sem at leo ullamcorper, volutpat orci ut, suscipit erat. Morbi tempor tortor vel urna lobortis. Hendrerit faucibus massa consequat. Vivamus feugiat sapien massa, non luctus purus scelerisque et. Donec sodales pellentesque diam, et adipiscing erat imperdiet ac. Integer a lacinia velit. Pellentesque eu adipiscing arcu, a eleifend nulla. Vivamus tempus sem erat, eget lobortis odio interdum at. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus et feugiat risus. Ut a egestas libero. Morbi dictum quis felis vel congue. Sed eu arcu auctor, volutpat justo et, egestas libero. Phasellus sagittis sem in iaculis faucibus. Aenean vel lacus purus.</p>
</div><!-- .portfolio-entry-excerpt -->




</div><!-- .portfolio-entry-details -->


</div><!-- .portfolio-entry -->



<div class="post-350 portfolio type-portfolio status-publish has-post-thumbnail hentry portfolio-entry span_1_of_1 col col-1 cat-38">



<div class="portfolio-entry-media">


<img src="http://ift.tt/1yiI4PX" width="222" height="167" class="portfolio-entry-img" alt="Carboxiterapia">



</div><!-- .portfolio-entry-media -->




<div class="portfolio-entry-details clr">



<h2 class="portfolio-entry-title entry-title">


<a href="http://ift.tt/1yiI4PY" title="Carboxiterapia">
Carboxiterapia </a>


</h2>




<div class="portfolio-entry-excerpt clr">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent pretium turpis rhoncus, ultrices quam vel, aliquam lorem. Suspendisse mattis nisl nibh, sit amet pharetra velit auctor vitae. In lacus nibh, bibendum vitae varius vitae, mollis at ipsum. Nullam fermentum purus arcu, sed fringilla libero imperdiet ac. Sed tincidunt fringilla nunc, sed sollicitudin ante interdum id.</p>
</div><!-- .portfolio-entry-excerpt -->




</div><!-- .portfolio-entry-details -->


</div><!-- .portfolio-entry -->



<div class="post-336 portfolio type-portfolio status-publish has-post-thumbnail hentry portfolio-entry span_1_of_1 col col-1 cat-38">



<div class="portfolio-entry-media">


<img src="http://ift.tt/1yiI4PZ" width="222" height="167" class="portfolio-entry-img" alt="Rinomodelación">



</div><!-- .portfolio-entry-media -->




<div class="portfolio-entry-details clr">



<h2 class="portfolio-entry-title entry-title">


<a href="http://ift.tt/1yiI3vt" title="Rinomodelación">
Rinomodelación </a>


</h2>




<div class="portfolio-entry-excerpt clr">
<p>Maecenas nec ultrices massa. Quisque orci diam, malesuada id augue nec, faucibus interdum dolor. Curabitur sagittis, felis porttitor placerat rhoncus, mauris diam sollicitudin nisl, sed luctus nulla sem non velit. Fusce a libero ullamcorper, volutpat orci ut, suscipit erat. Morbi tempor tortor vel urna lobortis. Hendrerit faucibus massa consequat. Vivamus feugiat sapien massa, non luctus purus scelerisque et. Donec sodales pellentesque diam, et adipiscing erat imperdiet ac. Integer a lacinia velit. Pellentesque eu adipiscing arcu, a eleifend nulla. Vivamus tempus sem erat, eget lobortis odio interdum at. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus et feugiat risus. Ut a egestas libero. Morbi dictum quis felis vel congue. Sed eu arcu auctor, volutpat justo et, egestas libero. Phasellus sagittis sem in iaculis faucibus. Aenean vel lacus purus.</p>
</div><!-- .portfolio-entry-excerpt -->




</div><!-- .portfolio-entry-details -->


</div><!-- .portfolio-entry -->



<div class="post-380 portfolio type-portfolio status-publish has-post-thumbnail hentry portfolio-entry span_1_of_1 col col-1 cat-38">



<div class="portfolio-entry-media">


<img src="http://ift.tt/1MbaiYJ" width="222" height="167" class="portfolio-entry-img" alt="Escleroterapia">



</div><!-- .portfolio-entry-media -->




<div class="portfolio-entry-details clr">



<h2 class="portfolio-entry-title entry-title">


<a href="http://ift.tt/1yiI4Q2" title="Escleroterapia">
Escleroterapia </a>


</h2>




<div class="portfolio-entry-excerpt clr">
<p>Maecenas nec ultrices massa. Quisque orci diam, malesuada id augue nec, faucibus interdum dolor. Curabitur sagittis, felis porttitor placerat rhoncus, mauris diam sollicitudin nisl, sed luctus nulla sem non velit. Fusce a libero ullamcorper, volutpat orci ut, suscipit erat. Morbi tempor tortor vel urna lobortis. Hendrerit faucibus massa consequat. Vivamus feugiat sapien massa, non luctus purus scelerisque et. Donec sodales pellentesque diam, et adipiscing erat imperdiet ac. Integer a lacinia velit. Pellentesque eu adipiscing arcu, a eleifend nulla. Vivamus tempus sem erat, eget lobortis odio interdum at. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus et feugiat risus. Ut a egestas libero. Morbi dictum quis felis vel congue. Sed eu arcu auctor, volutpat justo et, egestas libero. Phasellus sagittis sem in iaculis faucibus. Aenean vel lacus purus.</p>
</div><!-- .portfolio-entry-excerpt -->




</div><!-- .portfolio-entry-details -->


</div><!-- .portfolio-entry -->



<div class="post-371 portfolio type-portfolio status-publish has-post-thumbnail hentry portfolio-entry span_1_of_1 col col-1 cat-38">



<div class="portfolio-entry-media">


<img src="http://ift.tt/1MbaiYK" width="222" height="167" class="portfolio-entry-img" alt="Piel Perfecta">



</div><!-- .portfolio-entry-media -->




<div class="portfolio-entry-details clr">



<h2 class="portfolio-entry-title entry-title">


<a href="http://ift.tt/1MbagzS" title="Piel Perfecta">
Piel Perfecta </a>


</h2>




<div class="portfolio-entry-excerpt clr">
<p>Nullam volutpat libero vel dolor bibendum, vel vestibulum orci congue. Suspendisse potenti. Ut eu condimentum velit, in varius diam. Phasellus vitae arcu placerat, tristique mi ut, tincidunt leo. Aenean nec felis augue. Vivamus blandit turpis at dictum accumsan. Fusce adipiscing rutrum nibh, ac fermentum urna dictum eu. Nunc ullamcorper aliquet sagittis. Maecenas euismod lacus a pulvinar luctus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus et feugiat risus. Ut a egestas libero. Morbi dictum quis felis vel congue. Sed eu arcu auctor, volutpat justo et, egestas libero. Phasellus sagittis sem in iaculis faucibus. Aenean vel lacus purus.</p>
</div><!-- .portfolio-entry-excerpt -->




</div><!-- .portfolio-entry-details -->


</div><!-- .portfolio-entry -->



</div>




wp_get_attachment_image_src and server path


wp_get_attachment_image_src will give me URL and dimensions for an image.


But is there any way to get the server path for a scaled image (like /html/wordpress/wp-content/uploads/2015/03/cat-2-300x225.jpeg)? I know about get_attached_file but this returns only the original image.


I'd like to avoid hacky solutions (string-replacing domains and such) or using WP_Image_Editor directly. Also it should be multisite-proof. Is there something official I've just missed?





Wordpress Home page issue


At this point, I can only do changes to my home page at tomwitek.com by doing changes directly to html and uploading it to my server directly. My static page is set in the Reading to Home which was a page I created for displaying the tomwitek.com. The page i used was http://ift.tt/1HVQK3X


Now, I was able to change this page directly using pages panel and it would update the page at Home location. What happens right now is that even though I deleted the http://ift.tt/1HVQK3X at some point the home page was still loading as if the page was there, so now i can only make changes through html.index and only to homepage.


How do I fix this so that it goes back to me being able to do changes through wordpress pages panel instead of doing changes to index.html?


Also, whenever i do changes to index.html (for example I combined 38 css files into 2 (cant get it to one because it breaks my site in IE) these changes are not reflected on my other pages on the site (they still use the original calls for css and js so i get bad Google speed all around)


Which file caused this changes to happen, I am not sure if this was something I did or it happened when there was upgrade to wordpress or upgrade to php?


Help needed.





Is possible to add post-formats to custom-post-type?


I was wondering if there is some way to put together the custom-post-types and post-formats so I can code a new post type and offer some variations as post-formats.


I'm involved in a company directory conceptualization and we have to mix different kind of company. While almost all of this types share the same data fields, there are two specific kind of companies - hotels & bistros - which has especific requirements (custom taxonomies and some data fields).


In your opinion, which is the best approach?



  • Use three custom-post-type: 'company', 'bistro' & 'hotel'.

  • Use one custom-post-type w/ post-formats.

  • Use only one custom-post-type and use conditional logic to add or not specific data-models.


Thanks in advance!!!


Xavier





Category specific year archive list with desired URL


I am trying to make category specific year archive list.


I tried wp_get_archives() with type=yearly arg in which I got year lists with links.


2015

2014

...


and its link looked like this...

http://ift.tt/1F0GffG

Can I change this to something like

http://ift.tt/1D5Mq4r.


My permalink structure is set to

/%category%/%year%/%monthnum%/%day%/%post_id%/

and my category base is set to

.


Any help appreciated. Thank you for stopping by.





How can I integrate a lightweight payment process in my wordpress site? ¿WPe-Commerce?


I am on a wordpress website that is not a shop, the website offers information in maps. The issue is that the website offers a service of creating legal contracts. The logic is that a registered user gives the personal data, contract data, etc and then the owners of the website make a legal contract.


The point is that this action must be paid by the customers and I want to implement payment process.


I saw that I good option is to use Gravity Form with its payment plugins, but the prices is high.


I saw also that there is another way with WPe-Commerce, but I don't know if it's convenient to use for this purpose.





Dynamically send pdf attached to post with contact form 7 [2]


I'm come from this post : contact form 7


So i do the same exact code :



add_action('wpcf7_before_send_mail', 'my_dynamic_attachments');

function my_dynamic_attachments($cf7) {
$id = $cf7->id();
$upload_dir = wp_upload_dir('2015/03');
if ($id==1326){
$submission = WPCF7_Submission::get_instance();
$data = $submission->get_posted_data();
$pdf = $data['brochures'][0];
//echo $pdf;
$submission->add_uploaded_file('pdf', $upload_dir['path'].'/'.$pdf);
}
}


The problem is if file is sent only i uncomment the "echo". Since he was comment, file not be sent and i don't understand why ...


Have an idea ?


Thanks





I cannot customize custom widgets anymore after moving WordPress website


Originally posted here.


The situation is the following one: A colleague of mine built a WordPress theme with some custom widgets which need to be configured through /wp-admin/widgets.php.


In the local copy that me and him have installed everything works fine (it's the latest WP, the production database and the theme from bitbucket). The production is ok, but it's impossibile to change the widgets options since every widget has a There are no options for this widget. label.


So I did a setup from scratch: I created a new WP-ready droplet on Digital Ocean, imported the database I have locally (1:1 production since I changed my /etc/hosts to point the production domain to my localhost) and cloned the theme, but still I got the same issue of production: Widgets were not customizable. Also there are no references to localhost in wp_option rows.


tl;dr: With the same database and the same files, the website works fine locally while in the production machine (AWS) and in the staging droplet (DO) widgets are not customizable.





Failed to send your message. Please try later or contact the administrator by another method (contact form 7 )


i am new to wordpress . i am facing problem with contact us form. where will be the setting like SMTP or php mail for contact us form (i am using contact form 7 plugin . also i installed wp-smtp. ) i am getting the following error message


Failed to send your message. Please try later or contact the administrator by another method. with red border.


please help me out to solve this issue.





Duplicate slugs in wp Database


While updating a category I keep getting "Item not updated" message, after a little research I found that it is due to duplicate slugs in the database.


I know a slug cannot be duplicated, so now I am wondering how is this possible that database has duplicate entries for slug and how can I get rid of these?


I am using WP-ecommerce categories, where these errors keep coming. enter image description here


You can see the duplicate entries in term_id 27 & 963.





how do i make this loop work


Apologies I am a PHp beginner and I have no idea why this loop is not working on my tag.php page any help would be welcome.



<?php get_header(); ?>
<div class="posts"><!-- BLOG -->

<!-- Shapes on sides -->
<div class="shapes_left"> </div>
<div class="shapes_right"> </div>

<?php if (is_tag()) { ?>
<div id="archive_title">
<h1><?php single_tag_title(); ?></h1>
<?php }?>
</div>


<div id="featured_home">

<?php $counter = 0;
while ( have_posts() ) {
$counter += 1;
if ( $counter > 5 ) {
break;
}
the_post();

?>
<article class="sticky">
<div class="desc">
<div class="desc_over"><h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2></div>
<?php the_post_thumbnail(large); ?>


</div>
</article>
<?php }?>
</div>





<?php while( have_posts() ) {
the_post();
// it's a post! Display the post!
} ?>


<div class="post_main">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<ul class="postinfo">
<li>Posted by <?php the_author_link(); ?></li>
<li><?php the_time( 'jS F Y'); ?></li>
</ul>

<?php the_content( ''); ?>

<div class="read_more_blog"><a href="<?php the_permalink(); ?>">Read More</a></div>
</div>

<?php endwhile; ?>
<nav id="pagination"> <!-- PAGINATION FOR BLOG -->
<ul>
<li class="older"><?php next_posts_link( 'Older posts'); ?></li>
<li class="newer"><?php previous_posts_link( 'Newer posts'); ?></li>
</ul>
</nav>

</div>
<!-- END OF BLOG PAGINATION -->
<?php else : ?>
<div id="post">
<!-- 404 Messege -->
<h3>404 ERROR!!</h3>

<p>Sorry we can't seem able to find what you are looking for</p>
<p><a href="<?php echo home_url(); ?>">Click here to get back to the homepage</a>
</p>
</div>
<?php endif; ?>
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>




How do I change attachment slug from name to id


I need to change the slug of the attachment post. Currently, it is showing attachment name , I want it to be replaced by id of attachment.





Select box saves but doesn't update value in admin


I have a select dropdown in my custom meta box in the admin area. It offers two options Approved and In Progress. When I select an option and save it the database is updated, but the value in the admin area is not. What I see is the first item from the list displayed in the select box. i.e. if I select In Progress and save the admin shows Approved as the selected value even though it is saved as In Progress in the database and displays In Progress on the front end of the site.


Here is my code:



<label for="myplugin_meta_box_select">Status:</label>
<select name="myplugin_meta_box_select" id="myplugin_meta_box_select">
<option value="Approved" <?php selected( $selected, 'approved' ); ?>>Approved</option>
<option value="In Progress" <?php selected( $selected, 'inprogress' ); ?>>In Progress</option>
</select>


And I save it with this:



if( isset( $_POST['myplugin_meta_box_select'] ) )
update_post_meta( $post_id, 'myplugin_meta_box_select', esc_attr( $_POST['myplugin_meta_box_select'] ) );


What have I missed out?


Right, I should have pasted the whole code for my meta box at first, but I genuinely thought that it was just this snippet that was causing the problems. You live and learn. Here is my code: http://ift.tt/1OCbsev





adding more text to a query string


On a site I am developing, I need a "special search" function. The search page is called with a search query from a form with _GET parameters like this : http://ift.tt/1M9EHqj


In the search page itself (where the result will be), how can I concatenate the s1 and s2 arguments so the results for wordpress would be treated as if it receives: http://ift.tt/1NgTX1y


Thanks for your help





Query post using Advanced Custom fields (Text one textfield with multi values;comma separation)


Hi i developed a page template that query post through the use of ACF lets call it page-test.php with this code:



<?php

$appvalue = get_field('em_application_value');
$appexplode = explode(",",$appvalue);
$appimplode = implode(" or ",$appexplode);

$prodvalue = get_field('em_product_value');
$prodexplode = explode(",",$prodvalue);
$prodimplode = implode(" or ",$prodexplode);

$resultnum = get_field('em_number_of_results_to_show');

?>

<div style="margin: 5% 8.3333%">
<h1>Application <?php echo $appimplode; ?> and Product <?php echo $prodimplode; ?> results:</h1>
</div>


<?php



// args
$args = array(
'numberposts' => $resultnum,
'post_type' => 'post',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'em_application',
'value' => $appexplode,
'compare' => 'IN'
),
array(
'key' => 'em_product',
'value' => $prodexplode,
'compare' => 'IN'
)
)
);

// query
$the_query = new WP_Query( $args );
?>

<?php if( $the_query->have_posts() ): ?>
<?php
// Start the loop.
while ( $the_query->have_posts() ) : $the_query->the_post();

/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );

// If comments are open or we have at least one comment, load up the comment template.
/* if ( comments_open() || get_comments_number() ) :
comments_template();
endif; */

// End the loop.
endwhile;
?>
<?php else: ?>

<div style="margin: 5% 8.3333% 1%; background: #fff; padding: 5% 10%;">
Not found
</div>

<?php endif; ?>


Then In page editor when you select this template , custom fields will appear and I named them


em_application_value for Application textfield em_product_value for Product textfield em_number_of_results_to_show and for numeric field


The use of the template is to query posts through these custom fields. the first attempt was okay but when i tried to input multiple values the posts couldn't show in the frontend. Maybe i have an error for content.php (twentyfiftheen theme)


My only problem here is that what if the single post has multiple application and product values? let's say in one single textfield i can put multiple values separated with commas and i want the wordpress to detect that they are different values. how can page-test.php compare the words using "IN" . please help





Custom view on data


I created two custom post types - Company and Item. I established a relation between them using Posts2Posts plugin. What is the best, most correct way to create a template/view displaying all the items of a company.


Wordpress created this URLs for me: site/company/company_1 and site/item/item_1 . I want a link of format site/companies_items/company_1 which would display all the company_1's items.


Thank you for your time.





Adding new post format on plugin activation


I am adding new post format on my plugin activation using this code



wp_insert_term( 'post-format-interviews_ans', 'post_format' );


But it's not working the rest of the plugin activation code like table generation is working.


post_format is wordpress default texanomy type.


can any one let me know what is the issue.





jeudi 26 mars 2015

Which directories does WordPress attempt to create when updating core and installing plugins?


Which directories does WordPress 4 attempt to create when updating core and installing or upgrading plugins?


The purpose of the question is to gain understanding of the update process and spread that knowledge.





What is the correct way to map multiple domains in a WordPress 4.1 multisite install?


I'm aware of this question and others but have not found a definitive answer to how a domain should be set up with multisite so that www and non-www variants behave correctly. I believe I have wildcards set up correctly at the DNS level and the suggested solution to add define( 'NOBLOGREDIRECT', 'http://www.example.com' ); works for my main site but not other networks in the same install.


I am using the 'WP Multi Network' plugin based on some research which led me to the conclusion that if I am running several domains on one WordPress install, I should be using multiple networks, not just multisite. My Networks and sites are all added with www included in the domain field


So what is the correct way to map bare domains without www to a multisite install? Are plugins required? Should this all be handled in web server config using rewrites?





Using www along with non-www for main domain in multisite installation


I have a multisite installation that runs on Nginx.


In my site's configuration file, I have set the server block as:



server{
listen 80 default_server;
server_name example.com *.example.com;
server_name_in_redirect off;

access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;

root /var/www/example.com/htdocs;
index index.php;

if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}

location / {
try_files $uri $uri/ /index.php?$args;
}
}


Right now, whenever I enter www.example.com in the browser, I get redirected to example.com.


However, I want example.com to redirect to www.example.com.


I also plan to use HTTPS with www.example.com


What else do I need to add to my configuration file to make this happen?





different post types on same page in 2 separate columns


I'm pretty new to wordpress and am working on creating a child theme (parent theme is Avenue). I've created 2 different custom post types and now would like to display them on the same page in 2 different columns. I've created separate loops for them using different wp_queries for them to be called correctly. They show up on the page, but the only way I can get them to be side by side is to assign the right column with a margin-top of -500px. I know this is not the correct way of doing it and it is not very responsive. Below is my code. Any help would be greatly appreciated.


front-page: 'page', 'order' => 'ASC' ); $the_query = new WP_Query( $args );



$args_review = array(
'post_type' => 'reviews',
'order' => 'ASC'
);
$quote_query = new WP_Query( $args_review );

$args_links = array(
'post_type' => 'magazines',
'order' => 'ASC'
);
$link_query = new WP_Query( $args_links );
?>

<?php if ( have_posts() ) : while ( $the_query->have_posts()) :
$the_query->the_post(); ?>

<?php get_template_part('content', 'page'); ?>

<?php endwhile; endif; // end of the loop. ?>
<?php wp_reset_postdata(); ?>

<?php if ( have_posts() ) : while ( $quote_query->have_posts()) :
$quote_query->the_post(); ?>

<?php get_template_part('content_two', 'page'); ?>

<?php endwhile; endif; // end of the loop. ?>
<?php wp_reset_postdata(); ?>

<?php if ( have_posts() ) : while ( $link_query->have_posts()) :
$link_query->the_post(); ?>

<?php get_template_part('content_three', 'page'); ?>

<?php endwhile; endif; // end of the loop. ?>
<?php wp_reset_postdata(); ?>


content_two-page (this calls the first custom post)



<div class = "reviews-content">
<div class = "left_col">
<div class = "bg_quote">
<?php the_field('title'); ?>
</div>
<?php the_field('reviews'); ?>
<?php the_field('date'); ?>
</div>
</div>


content_three-page (this calls the second custom post)



<div class = "mag-content">
<div class = "right_col test">
<?php the_field ( 'links' ); ?>
<?php the_field ( 'summary' ); ?>
</div>
</div>




WP_load, shortinit for wordpress Ajax


We have been using wp-load.php for ajax load. it's for showing a popup when you click "preview". As you may know it takes very long time (3~4 sec) for get even a few texts.


We have searched and found that "short init" is the solution to make it faster load.


But it seems to be little hard to get wp functions. when we use "wp-load", we used these functions.



Wordpress functions
=================================
get_post_meta
apply_filters
$wpdb( wp_prefix ) ===> to find multi network prefix
get_option
wp_upload_dir
get_current_blog_id
_e, __
get_userdata
get_post
get_the_post_thumbnail
wp_get_attachment_image_src
get_permalink
wp_get_object_terms
wp_remote_retrieve_body
wp_remote_get

WPML
====================================
icl_get_languages


How can I call/declare these functions to use shortinit function. we really need to make ajax load fast and need to use wordpress functions.


This is our codes sample. is this a correct way to do?



<?php
ini_set('html_errors', 0);
define('SHORTINIT', true);

require_once $_SERVER['DOCUMENT_ROOT' ] . "/wp-load.php";
require_once ABSPATH . WPINC . '/formatting.php';
require_once ABSPATH . WPINC . '/meta.php';
require_once ABSPATH . WPINC . '/post.php';
require_once ABSPATH . WPINC . '/user.php';
require_once ABSPATH . WPINC . '/capabilities.php';

header( 'Content-Type: application/json; charset:utf-8' );

$wpk_result = Array( "state" => "fail" );
if( $post_id = $_REQUEST["post_id"] )
{
$post = get_post( $post_id );
$wpk_this_author = new WP_User( $post->author );
$wpk_this_thumb = '';

// Other Informations
$wpk_result = Array(
'state' => 'success'
, 'post_id' => $post->ID
, 'post_title' => $post->post_title
//, 'permalink' => get_permalink( $post->ID )
, 'thumbnail' => $wpk_this_thumb
, 'phone' => get_post_meta( $post->ID, 'jv_item_phone', true )
, 'website' => get_post_meta( $post->ID, 'jv_item_website', true )
, 'email' => get_post_meta( $post->ID, 'jv_item_email', true )
, 'address' => get_post_meta( $post->ID, 'jv_item_address', true )
, 'author_name' => $wpk_this_author->display_name
);
}
die( json_encode( $wpk_result ) );


We need to keep adding file names to define the functions we need? for getting thumnail images, it needs so many function files we need to require.


We have also checked "theme checker" plugin. ini_set('html_errors', 0); is a bad practice.





How to switch subdomain with root domain and redirect traffic?


I want to move subdomain to root, and create a new root. I have root.com. I want to move it to sub.root.com and install a new Wordpress intall at root.com. Any idea how I redirect the traffic from root to sub.root without affecting the new site? Or do I just have to move, wait for the search engines to redirect and then install the new copy on root.com?





PHP if url extension action=discussion condition use


I want use some style only for url extension /?action=discussion How can I use it by PHP condition?





Custom Post Type with for Custom User Roles with restricted admin dashboard


I want to achieve the following functionality without use of a plugin:



  1. Create a new user role called "News Manager"

  2. Create a new custom post type called "News"

  3. Assign the capability of posting News to "News Manager"


However, since there are lots of other custom post types in my theme, I want that the person who is a News Manager should not be able to have access to any other types of content from the admin dashboard except uploading unfiltered html and media. I implemented this code with find-replace 'projects' with 'news' but somehow unable to achieve this functionality. Please help.





php create wordpress post programmatically


i want to create video gallery plugin i am using this code to create post by code using php



global $user_ID;
$new_post = array(
'post_title' => 'chapter1',
'post_content' => 'Lorem ipsum dolor sit amet...',
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => $user_ID,
'post_type' => 'post',
'post_category' => array(0)
);
$post_id = wp_insert_post($new_post);


its working well but problem is, created post is showing in admin dashboard "All post" panel. i don't want to show programmatically created post there. or in a latest post. is there any way i can do this . i tried to change post type but after that genrated post link give me page not found error.





How to customize Generate-Pro theme blog posts?


So how do I customize each blog post entry for the Genesis Generate Pro Theme? Specifically I want to:


1) Add a mailing list optin from GetResponse by pasting the following code at the bottom of each blog post:



<script type="text/javascript" src="http://ift.tt/1D4eWDx"></script>


2) Remove the vertical gray/black bar (circled in red in attached pic) that is to the left of each title of each blog post and possibly not display the blog post title as well.


enter image description here





Issue using wp-load.php in WordPress Plugin Development


Why it is bad to use this


include("../../../wp-load.php"); ??


What is the proper way of use this??


Thanks





Wordpress email reply back to the original post author


So, I don't know how to explain properly, but here is the current situation.


Let say the site is called "Demo.com" and site admin email is "admin@gmail.com"


Then,



  1. An author(example, user-X@gmail.com) posts a post.

  2. a visitor (another user, user-Y@gmail.com) leaves a comment or reply on the post.

  3. the author(user-X) gets an email notification.


Here is the thing.


The email sender is the admin "admin@gmail.com" and not the visitor.


Thus, when the author tries to reply back directly from the email, he is replying back to the "admin@gmail.com" and not "user-y@gmail.com".


How can I change it so that the reply can be sent to the original viewer (user-y)?


Any suggestions?





How can I add a time to woocommerce sale schedule date


Woocommerce has the ability to apply a sale price for a product and schedule it with a start and end date. the widget to select the date does not include a time for the sale to start. I'm familiar with php/wp programming but looking for a simple way (hack ...) to allow time selection for the sale. is it just a matter of modifying the widget?





Can I have two child pages of different parents with the same name?


I have two pages - http://ift.tt/192ahEi - http://ift.tt/192ahEk


Both pages are displaying the content for the /hills/sisterhood site but they are different pages with different content. I can't seem to find anything online about this. Is this possible? Are there any ways to make this work.


Thanks for the help! Paul





Custom Post Status to "Disapprove"


I'm working with the "events manager" plugin and I need help to implement the following:



  1. Admin can select custom post status of "Disapprove" which will automatically send an e-mail to the author of the post that it has not been approved and then automatically delete the post.


I'm aware that the #12706 ticket was created 5 years ago. Is there any way to implement this?





How to align last 3 menu items to the right


I would like create a menu with the first 3 items aligned to the left and last 3 items aligned to the right.


MENU:



<UL>
<li>1a</li><li>2a</li><li>3a</li> <-left right-> <li>4a</li><li>5a</li><li>6a</li>
</UL>


Using float left and right causes the last 3 items to change order, I need them to stay in order.


I would like a solution that does not require creating a separate menu or changing the order of the menu items to make the float:right put them back in the right order.





Custom post type, permalinks, taxonomies and blog posts


I am creating a custom theme for a bike shop and thought having a custom post type for bikes would be easier for the shop assistant to manage the bikes they would like to appear on their website rather than have a huge amount of child pages.


To start things off, here is my code for the bikes custom post type in functions.php



/*
* Register `bikes` post type
*/
function bikes_post_type() {

// Labels
$labels = array(
'name' => _x("Bikes", "post type general name"),
'singular_name' => _x("Bike", "post type singular name"),
'menu_name' => 'Bikes',
'add_new' => _x("Add New", "bike item"),
'add_new_item' => __("Add New Bike"),
'edit_item' => __("Edit Bike"),
'new_item' => __("New Bike"),
'view_item' => __("View Bike"),
'search_items' => __("Search Bikes"),
'not_found' => __("No Bikes Found"),
'not_found_in_trash' => __("No Bikes Found in Trash"),
'parent_item_colon' => ''
);

// Register post type
register_post_type('bikes' , array(
'labels' => $labels,
'public' => true,
'has_archive' => false,
'rewrite' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/images/icon-bikes.png',
'supports' => array('title', 'editor', 'thumbnail'),
//'taxonomies' => array( 'category', 'post_tag' ),
//'rewrite' => array('slug' => 'bikes', 'with_front' => false,)
) );
}
add_action( 'init', 'bikes_post_type' );


/*
* Register `bikes` taxonomy
*/
function bikes_taxonomy() {

// Labels
$singular = 'Bikes Category';
$plural = 'Bikes Categories';
$labels = array(
'name' => _x( $plural, "taxonomy general name"),
'singular_name' => _x( $singular, "taxonomy singular name"),
'search_items' => __("Search $singular"),
'all_items' => __("All $singular"),
'parent_item' => __("Parent $singular"),
'parent_item_colon' => __("Parent $singular:"),
'edit_item' => __("Edit $singular"),
'update_item' => __("Update $singular"),
'add_new_item' => __("Add New $singular"),
'new_item_name' => __("New $singular Name"),
);

// Register and attach to 'bikes' post type
register_taxonomy( 'bikes_category', 'bikes', array(
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'hierarchical' => true,
'query_var' => true,
'labels' => $labels,
//'rewrite' => array('slug' => 'bikes', 'with_front' => false),
) );
}
add_action( 'init', 'bikes_taxonomy');


The commented out lines at the end of the register_post_type() and register_taxonomy() functions are causing a problem for me.


The permalink structure I have set is /blog/%year%/%monthnum%/%postname%/ as that is the way I would like the blog posts to be structured.


The page hierarchy is set up like this: domain.com/bikes/


http://ift.tt/1IAZKwm


http://ift.tt/1bzgqJR


The /bikes/ page will be a landing page of sorts with some text about bikes in general as well as a sentence or two regarding mountain bikes and road bikes with links to the child landing pages /bikes/mountain-bikes/ and /bikes/road-bikes/.


When I create a new bike, the permalink is /blog/bikes/giant-anthem-x-29er/. I would like the permalink to be something like /bikes/giant-anthem-x-29er/ or /bikes/mountain/giant-anthem-x-29er/. I managed to get /bikes/giant-anthem-x-29er/ to work by changing the permalink setting to /%year%/%monthnum%/%postname%/ but that gave me a 404 error for /bikes/mountain-bikes/ and a permalink for the blog posts without 'blog', which is not what I would like to happen.


I've googled and searched through this site but I can't seem to find anything that will allow me to have an architecture like this:


/bikes/ - standard page template


/bikes/mountain-bikes/ - standard page template


/bikes/road-bikes/ - standard page template


/bikes/mountain-bikes/ - standard page template


/blog/ - default template


/blog/%year%/%monthnum%/%post-name%/ - single post template


/bikes/giant-anthem-x-29er/ - custom bike template (with example slug from the custom post type)


or


/bikes/mountain/giant-anthem-x-29er/ - custom bike template (with taxonomy in the permalink)


Any help in achieving this would be greatly appreciated.





html2canvas - It works in JSFiddle, but not in Wordpress


I am trying to get this code from JSFiddle to work in my WP install (http://ift.tt/1BoLEJy). I am having no luck. I am a novice JS user, but relatively experienced with WP. Here's what I've done so far:



  1. Copied HTML to the text editor of a new page in WP

  2. Copied the javascript code to a script box on the page and surrounded it with script tags <script type="text/javascript"></script>

  3. Copied the CSS to the script box and surrounded it with <style> tags


I haven't done anything else. I'm not sure if I need to upload any files, or add other items. Any thoughts?


Update:


Here's a test page I've created to try to replicate the JS Fiddle (goo.gl/dkXCEC)


I have added the html2canvas.js to my template's js folder. Then, I added the following enqueueing script to my functions.php file. This script was taken from http://ift.tt/1Hqk3ie (search for Google analytics example on the Codex page)



/* ------------ Enqueueing Script --------------- */

add_action( 'wp_enqueue_scripts', 'promo_canvas' );

/**
* Register and enqueue a script that does not depend on a JavaScript library.
*/
function promo_canvas() {
wp_register_script(
'html2canvas',
'/wp-content/themes/news-pro/js/html2canvas.js',
false,
'1.0',
true
);

wp_enqueue_script( 'html2canvas' );
}




Enqueue script on specific WooCommerce template


I would like to enqueue a lightbox script on the WooCommerce page content-single-product.php.


I have tried the following via functions.php:



if(is_page_template( 'page-gallery.php' ) || is_page_template( 'content-single-product.php' )) {
wp_enqueue_script( 'theme-lightbox', get_template_directory_uri() . '/js/lightbox.js', array(), '20150323', true );
}


The script loads correctly on page-gallery.php, but not on the WooCommerce single product page. I assume this method only works for my theme page templates?





Custom Post Type and Taxonomies


I hope someone here can help me with a bit of a problem.


I am working on a WP site where I have created a Custom Post Type called Retailer.


In there I have Country, Region and City


Now I want to filter these taxonomies based upon 1. Country - Ex. Denmark 2. Region - if Denmark is chosen in country show Regions in Denmark 3. City - And when Country and Region is chosen show the cities of the Region.


Hope someone can point me in a direction on how to achive this.





Display Pages in Portfolio Layout


I am using Avada theme in my Wordpress site. I wanted to know if it's possible to show a list of specific (subpages) pages in a portfolio layout? Just like the normal portfolio template, but showing pages instead of portfolio custom items.


Thank you,





Create page from plugin, but have it completely hidden


I need to have a plugin create a page that is publicly accessible, but does NOT show up in the admin section anywhere, and cannot be deleted or modified.


I thought maybe figuring out a way to have a publicly accessible page that doesn't really "exist" in the database might be the way to go, but I couldn't figure it out.


I just don't want any user to be able to delete or modify the page.





Why are iframes from WordPress oEmbed stripped with wp_kses_post?


The docs for wp_kses_post() say "Sanitize content for allowed HTML tags for post content." iframe in general is an allowed tag, but more specifically I think it should allow tags created by WordPress for posts via oEmbed.


Is this a deliberate choice, or an oversight?





Re use the list table for a custom post type on another page


i've got a custom post type which is 'ai1ec_event'. So i have a "All events" page which has a Wp_List_Table with all my events and my customization to that table.


Is there a way to draw the same list table on a different page, without extending Wp_List_table but just reusing something?





Wordpress wp_link_pages show only next/prev link


I used nextpage to separate a post into multiple page and I don't want to show pagination as 1 2 3 Next, I want to to show Prev Next, below is the code I come up with after reading the wp link pages, it is still showing 1 2 3 Next, I don't know what I did wrong, any help will be much appreciated



<?php
wp_link_pages( array( 'before' => '', 'after' => '',
'previouspagelink' => '', 'nextpagelink' => '<span>Next post</span>',
'next_or_number' => 'next' ) );
?>




Front End Editor Looping content


I have an issue with Wp-Front-end Editor looping the contents on a page twice when editing mode is turned on.


And i've searched online trying to get a solution, but to no avail.


Has any other person experienced this issue with Wp-Front-end editor?





Set product_type via front end


my problem is to set the “product_type” as Auction without “Custom Taxonomies” but with a hidden field so as not to show anything to the user. How can I do?


I use "wp simple auction" and "WP User Frontend"


Thanks in advance





Use subdomain for certain urls


I have the following rules in my .htaccess file on a WordPress (single installation):



# REWRITE FORUMS DOMAIN TO FOLDER
RewriteCond %{HTTP_HOST} ^forums\.example\.com$
RewriteRule !^forums/? forums%{REQUEST_URI} [NC,L]

# REWRITE FORUMS FOLDER TO SUBDOMAIN
RewriteCond %{THE_REQUEST} \s/forums/([^\s]*) [NC]
RewriteRule ^ http://ift.tt/1IpFWfw [R=301,L]


This is so that the forums that exist at http://ift.tt/1jBarQy are accessed at http://ift.tt/11ksZ6O


However the server just blows up with a 500 server error...


Any ideas on how to do this? These rules work perfectly when used on non-wordpress sites... The second rewrite rules successfully send /forums to the sub domain but the subdomain doesn't seem to be able to pass the data into WordPress correctly.'


The whole htaccess file looks like:



<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# REWRITE FORUMS DOMAIN TO FOLDER
RewriteCond %{HTTP_HOST} ^forums\.example\.com$
RewriteRule !^forums/? forums%{REQUEST_URI} [NC,L]

# REWRITE FORUMS FOLDER TO SUBDOMAIN
RewriteCond %{THE_REQUEST} \s/forums/([^\s]*) [NC]
RewriteRule ^ http://ift.tt/1IpFWfw [R=301,L]

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

</IfModule>


The reason that the WordPress rules are after the forums rules are because if I put them after then they are never hit!





How To Customise WordPress Comment Submit Button?


I am trying to customise the output code of



<?php comment_form(); ?>


At the moment the submit button outputs the following:



<p class="form-submit">
<input name="submit" type="submit" id="submit" value="Post Comment">
<input type="hidden" name="comment_post_ID" value="486" id="comment_post_ID">
<input type="hidden" name="comment_parent" id="comment_parent" value="0">
</p>


I would like it to output the following:



<div class="panel-footer">
<input name="submit" type="submit" id="submit" value="Post Comment">
<input type="hidden" name="comment_post_ID" value="486" id="comment_post_ID">
<input type="hidden" name="comment_parent" id="comment_parent" value="0">
</div>


I now we can achieve this using css or jquery. But any solution using wordpress functions will be great.


Any suggestions greatly appreciated! :)





How do i put in user id in a banner


I would like to know how im gonna put in a user id in a banner.


For example. I have 5 logged in persons on my page, and 3 of them has clicked on the same banner, but I need to know who is clicking.


My affiliate has this banner and told me to put in &uid= in the link, but I want to automatically put in the user id after that.


Here is the link, where I placed the &uid= as I was told. but what should I write after that, so it would show the user id on my affilates page, when maybe user 5 and user 18 is clicking on the link.?


enter image description hereWhat to do.





  when I use ENTER for skipping line


I don't know why when I'm using "Enter", that add &nbsp in Pages/Posts Editor. That doesn't matter, but on my website, when I look the code &nbsp makes this code :



<p> � </p>


and � appears on my website...


How can I change that to simple code :



<p> </p>


Or just hide the "�"





How can I get a list with all custom fields within Wordpress?


How can I get a list with all custom fields within Wordpress? I have tried the get_post_custom() function but that gives me only a list of custom fields for a post.


Thanks in advance.


/Mattias





How to display Categories as a index page style (wordpress)



<div id="main" role="main">
<header id="introduction" class="contain">
<hgroup>
<?php
$title = __( 'Archives', 'parament' );
$description = '';
if ( is_tag() ) {
$title = single_tag_title( '', false );
$description = tag_description();
if ( empty( $description ) )
$description = sprintf( __( 'All posts tagged %1$s', 'parament' ), $title );
} elseif ( is_category() ) {
$title = single_cat_title( '', false );
$description = category_description();
} elseif ( is_day() ) {
$description = sprintf( __( 'All posts for the day %1$s', 'parament' ), esc_html( get_the_date( __( 'F jS, Y', 'parament' ) ) ) );
} elseif ( is_month() ) {
$description = sprintf( __( 'All posts for the month %1$s', 'parament' ), esc_html( get_the_date( __( 'F, Y', 'parament' ) ) ) );
} elseif ( is_year() ) {
$description = sprintf( __( 'All posts for the year %1$s', 'parament' ), esc_html( get_the_date( __( 'Y', 'parament' ) ) ) );
} elseif ( is_author() ) {
the_post();
$description = sprintf( __( 'All posts by %1$s', 'parament' ), esc_html( get_the_author() ) );
rewind_posts();
}

if ( ! empty( $title ) ) {
echo '<h1 id="page-title">' . $title . '</h1>';
}

if ( ! empty( $description ) ) {
echo '<h2 id="page-tagline">' . $description . '</h2>';
}
?>
</hgroup>
</header>

<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'content', '404' ); ?>
<?php endif; ?>

<nav id="posts-nav" class="paged-navigation contain">
<h1 class="assistive-text"><?php _e( 'Posts navigation', 'parament' ); ?></h1>
<div class="nav-older"><?php next_posts_link( __( '&larr; Older Entries', 'parament' ) ); ?></div>
<div class="nav-newer"><?php previous_posts_link( __( 'Newer Entries &rarr;', 'parament' ) ); ?></div>
</nav>

</div><!-- end main -->

<?php get_sidebar(); ?>




How can I add jTable in admin page?


I am really having a hard time to integrate jTable ang jquery-ui in my plugin's admin page, can somebody help me, I already tried adding it through admin_enqueue_script but still no luck. I've tried viewing the page source in my browser and the scripts seems to be loaded already, but still got nothing.


link to jTable : http://ift.tt/1txSWuy


Thanks in advance!


Here's my code:



// add actions
add_action('admin_init' , 'wog_membership_init ');
add_action('admin_enqueue_scripts', 'wog_requests_scripts' );
add_action('admin_menu', 'wog_requests_tab');


function wog_requests_tab(){
global $wog_member_admin_page;
add_menu_page( 'Requests Manager', "WOG Request Manager", 'manage_options', "wog_membership_requests");
$wog_member_admin_page = add_submenu_page( "wog_membership_requests", "Membership Requests", "Membership Requests", 'manage_options', "wog_membership_requests", "wog_membership_render");
}

//Enqueue my scripts
function wog_requests_scripts($hook){

global $wog_member_admin_page;
if ($hook != $wog_member_admin_page) {
return;
}
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script ('jquery-ui-tabs');
wp_enqueue_script ('wog-jtable-script');
wp_enqueue_style ('wog-jtable-style');
}

// registering my scripts and style
function wog_membership_init () {
wp_register_script ('wog-jtable-script', plugins_url( '/wog-request-manager/jtable/scripts/jtable/jquery.jtable.js', __FILE__ ));
wp_register_style ('wog-jtable-style', plugins_url( '/wog-request-manager/jtable/scripts/jtable/themes/metro/blue/jtable.min.css', __FILE__ ));

}

function wog_membership_render(){
?>

<div id="RequestManagerContainer" style="width: 600px;"></div>
<script type="text/javascript">

$(document).ready(function () {
//Prepare jTable
$('#RequestManagerContainer').jtable({
title: 'Table of people',
actions: {
listAction: '',
createAction: '',
updateAction: '',
deleteAction: ''
},
fields: {
PersonId: {
key: true,
create: false,
edit: false,
list: false
},
Name: {
title: 'Author Name',
width: '40%'
},
Age: {
title: 'Age',
width: '20%'
},
RecordDate: {
title: 'Record date',
width: '30%',
type: 'date',
create: false,
edit: false
}
}
});

//Loading the container
$('#RequestManagerContainer').jtable('load');

});

</script>

<?php

}




How to connect form data to database


i use contact-form-7-to-database-extension plugin to connect contact form 7 forms to the database. after i enter form data and submit it it says: "Failed to send your message. Please try later or contact the administrator by another method." Entering in the plugin' data section i found the form data is saved. why the error message is displayed then?





Getting cat-category_nicename as class only if has_category


I'm currently displaying a class on post items like cat-category_nicename (i.e. cat-press) using the below:-



$categories = get_the_category($post->ID);
foreach( $categories as $category ) {
// Category Class
$cat_class = 'cat-' . $category->category_nicename;
}


But on custom post types, has_category returns false and with the above, a class is output (the same one for all custom post types of a category - which it doesn't belong to).


How can I only display $cat_class if the post belongs to a category?





WordPress Plugin Boilerplate - add_action hook in static "activate" function


I'm hoping someone can point me in the right direction here.


I'm using the Wordpress Plugin Boilerplate to develop a custom plugin. On install, the plugin will register a new post type (course), a new taxonomy (course-areas) and set up permalink structures for the new post type and taxonomy.


I've added my code (to create the post type and taxonomy) to the Activator class as below, but the code doesn't appear to run, I'd guess it's caused by the add_action hook I'm using (namely the 'init' hook as recommended by the codex for plugin installs) as the code will run as intended if I call it within the main plugin file (iwcollege-courses.php) but I'm really not sure.


It's worth noting I'm not receiving any errors when activating the plugin, it appears to activate successfully, but no custom post types or taxonomies are created.


Any ideas on why this is happening and how I can remedy this?


Thanks in advance,


Aaron Bentley :)


iwcollege-courses.php



// The Activator class is called by the following code within the main plugin file as below:

function activate_IWCollege_Courses() {
require_once plugin_dir_path( __FILE__ ) . 'includes/class-iwcollege-courses-activator.php';
IWCollege_Courses_Activator::activate();
}

register_activation_hook( __FILE__, 'activate_IWCollege_Courses' );


class-iwcollege-courses-activator.php



class IWCollege_Courses_Activator {

public static function activate() {

add_action( 'init', array( get_called_class(), 'create_course_post_type' ), 0 );
add_action( 'init', array( get_called_class(), 'create_course_area_taxonomies'), 0 );
add_filter( 'post_type_link', array( get_called_class(), 'course_permalink_structure'), 10, 4 );

flush_rewrite_rules();
}

public static function create_course_post_type() {

$labels = array(
'name' => 'Courses', 'post type general name',
'singular_name' => 'Course', 'post type singular name',
'add_new' => 'Add New', 'Course',
'add_new_item' => 'Add New Course',
'edit_item' => 'Edit Course',
'new_item' => 'New Course',
'all_items' => 'All Courses',
'view_item' => 'View Course',
'search_items' => 'Search Courses',
'not_found' => 'No Courses found',
'not_found_in_trash' => 'No Courses found in the Trash',
'parent_item_colon' => '',
'menu_name' => 'Courses',
'menu-icon' => 'dashicons-list-view'
);

$supports = array (
'title',
'editor',
'thumbnail',
'excerpt',
'revisions'
);

$capabilities = array(
'create_posts' => false
);

$rewrite = array(
'slug' => 'course-area/%course_areas_taxonomy%/courses',
'with_front' => true,
'hierarchical' => false
);

$args = array(
'labels' => $labels,
'supports' => $supports,
'description' => 'Holds IWCollege Course data',
'public' => true,
'rewrite' => $rewrite,
'menu_position' => 5,
'has_archive' => true,
'taxonomies' => array('post_tag'),
'capabilities' => $capabilities,
'map_meta_cap' => true,
'public' => true,
'query_var' => true,
'publicly_queryable' => true

);

register_post_type( 'course', $args );
}


public static function create_course_area_taxonomies() {

$labels = array(
'name' => 'Course Areas', 'taxonomy general name',
'singular_name' => 'Course Area', 'taxonomy singular name',
'search_items' => 'Search Course Areas',
'all_items' => 'All Course Areas',
'parent_item' => 'Parent Course Area',
'parent_item_colon' => 'Parent Course Area:',
'edit_item' => 'Edit Course Area',
'update_item' => 'Update Course Area',
'add_new_item' => 'Add New Course Area',
'new_item_name' => 'New Course Area Name',
'menu_name' => 'Course Areas',
'popular_items' => null
);

$rewrite = array(
'slug' => 'course-area',
'with_front' => true,
'hierarchical' => true,
'ep_mask' => 'ep-mask'
);

$capabilities = array(
'manage_terms' => true,
'edit_terms' => true,
'delete_terms' => false,
'assign_terms' => false
);

$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => false,
'query_var' => true,
'sort' => false,
'public' => false,
'rewrite' => $rewrite,
'capabilities' => $capabilities,
'update_count_callback' => '_update_post_term_count'
);

register_taxonomy( 'course_areas_taxonomy', array('course'), $args );

register_taxonomy_for_object_type( 'course_areas_taxonomy', 'course' );

}


public static function course_permalink_structure ($post_link, $post, $leavename, $sample) {

if ( strpos( $post_link, '%course_areas_taxonomy%' ) !== false ) {

$course_post_type_term = get_the_terms( $post->ID, 'course_areas_taxonomy' );
$post_link = str_replace( '%course_areas_taxonomy%', array_pop( $course_post_type_term )->slug, $post_link );
}

return $post_link;
}
}




Why does Simplepie return feed items in a wrong order?


I have this feed from picasa (correct but arbitrary, desired order).


The result is messed up


Also, with this feed, for example.


It's fine in regular, sorted by date feeds, but not these. In the object I get from Simplepie it has a messed up order. I don't do anything fancy just loop over the results and display them in the found order using my commercial gallery plugin.


$rss_items = $rss->get_items(0, $rss->get_item_quantity($limit));


I have tried this (hooked into wp_feed_options) but it doesn't change anything: $rss->enable_order_by_date(false);


Also, when I do var_dump($rss_items); I get an array that is represented by 546503 lines of text. I don't believe that's normal, maybe it also hogs the memory, but I can't even look through that data manually to see if the order is inherently bad or just gets mixed up somewhere.


Also I can't tell if it's Simplepie's or WordPress' wrapper's fault.





Update user meta without lose of old data


Is this is possible to update the user meta without lose the old data it have ?


For example :


i have the following data in my user meta field name user_documents



a:4:{i:0;s:36:"817fb3ec8e2412b141bcc40c1e16d4c9.jpg";i:1;i:91;i:2;s:27:"8769106-alone-wallpaper.jpg";i:3;i:92;}


this is about the attached files with the user_documents meta, if suppose a user upload more files i want to store it into the user_documents again but without lose the old meta which is above.





(Securely) registering a new user via JSON API with a custom Zapier action


I want to use Zapier to register a new Wordpress user — the trigger will be a new purchase on Gumroad.


This plugin — http://ift.tt/1reRPhF — allows you to register users using a public JSON interface, eg by hitting http://ift.tt/1ybHXpp


I'm new to all this, but know that I can get Zapier to insert the purchaser's email from Gumroad into {{email}}.


My question is, how can I do this in a secure way?


(At the moment anyone can hit http://ift.tt/1D14Y5Y and get the key they need)


And maybe it can even be done without using Zapier?





Select box saves but doesn't update value in admin


I have a select dropdown in my custom meta box in the admin area. It offers two options Approved and In Progress. When I select an option and save it the database is updated, but the value in the admin area is not. What I see is the first item from the list displayed in the select box. i.e. if I select In Progress and save the admin shows Approved as the selected value even though it is saved as In Progress in the database and displays In Progress on the front end of the site.


Here is my code:


<label for="myplugin_meta_box_select">Status:</label> <select name="myplugin_meta_box_select" id="myplugin_meta_box_select"> <option value="Approved" <?php selected( $selected, 'approved' ); ?>>Approved</option> <option value="In Progress" <?php selected( $selected, 'inprogress' ); ?>>In Progress</option> </select>


And I save it with this:


if( isset( $_POST['myplugin_meta_box_select'] ) ) update_post_meta( $post_id, 'myplugin_meta_box_select', esc_attr( $_POST['myplugin_meta_box_select'] ) );


What have I missed out?


On a side note, I have check boxes in the admin area as well and they display the updates perfectly when saved.





How do I only display children of a parent page from a search?


I would like to have a search box on a page which only displays children of a parent page in the results - can someone help please.


I dont understand all the css and php coding as i am a newbie to this, so while i appreciate answers may have to include this coding, i wouldnt understand it. If you can answer in English it would be really appreciated.


Thanks





Adding css class to post and styling it


I am new to wordpress development, and I am using the Customizr Theme


I am trying to add a CSS class into my wordpress post in order to incorporate styles into it but I am having difficulty finding any tutorial or guide to help me understand how this is accomplished. I am able to use


post content

for instance but when I cant seem to use


post content

(with .postclass defined in style.css of my child theme)


I have studied briefly on hooks and filters. And read up on the wordpress loop.


Is there a guide or tutorial that you guys can recommend I read up on in order to get this achieved? It seems like such a simple thing to do but I cant figure it out.


Thanks,





WordPress meta_query not working


I am having issues with a meta query on a custom post type.


The following arguments are set:



$args = array(
'post_type' => 'wp_comp_entries',
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'wp_comp_entry_competition-id',
'value' => $_POST['competition-id'],
'compare' => '=',
),
array(
'key' => 'wp_comp_entry_email',
'value' => $_POST['email'],
'compare' => '=',
),
),
);


A print_r of this looks like:



Array
(
[post_type] => wp_comp_entries
[posts_per_page] => -1
[meta_query] => Array
(
[relation] => AND
[0] => Array
(
[key] => wp_comp_entry_competition-id
[value] => 972
[compare] => =
)

[1] => Array
(
[key] => wp_comp_entry_email
[value] => dan@tailored.im
[compare] => =
)

)

)


Which is great. I then run



$lookup = new WP_Query( $args );


The start of a print_r of $lookup looks like:



WP_Query Object
(
[query_vars] => Array
(
[post_type] => wp_comp_entries
[posts_per_page] => -1
[meta_query] => Array
(
)


As you can see the meta_query is empty. I have no idea what is causing this as at the bottom of that dump there is this:



[query] => Array
(
[post_type] => wp_comp_entries
[posts_per_page] => -1
[meta_query] => Array
(
[relation] => AND
[0] => Array
(
[key] => wp_comp_entry_competition-id
[value] => 972
[compare] => =
)

[1] => Array
(
[key] => wp_comp_entry_email
[value] => dan@tailored.im
[compare] => =
)

)

)


Which shows that my code is recognised, WP just isn't feeding it into it's query. I am lost and looking for any direction on why this could not be working?


-- EDIT --


I must add I have tried the standard query from the Codex with no joy either.





Adding and styling a css class for a wordpress post


I am new to wordpress development, and I am currently using the Customizr theme.


I have been searching for days on how exactly I am able to add a CSS class to a Wordpress post, and be able to style it.


I realize I am able to add in html for instance but I cant seem to add a class to it and subsequently adding style to that classname.


I know I may be lacking a lot of knowledge, is there a guide you guys can recommend so I may eventually learn how to do this? I have studied how to work with hooks and also briefly on how the loop works, but have yet to tested it out.


Thanks,





Wordpress Rewrite Issue


I created a custom taxonomy, two actually (one tag and one category), for a page that lists a series of community projects. This is the parent URL:



http://ift.tt/1D0Srzu


If you go here you'll see ALL the projects. I've successfully set up query vars so that if you enter say:



http://ift.tt/1IxUkCq


or



http://ift.tt/1D0SpHM


everything works as it should. It's perfect. Now, naturally, I'm trying to set up pretty permalinks so that users would simply be able to enter



http://ift.tt/1IxUkCr


and



http://ift.tt/1D0SpHO


respectively. I feel as if the issue may have something to do with the fact that I'm trying to rewrite on a child page of the root (/community)


Anyhow, this is my rewrite function. I've tried a bunch of deviations but I can't see to hit the mark here. I'm remembering to flush as well.



add_action('init','add_community_rewrite_rules');
function add_community_rewrite_rules()
{
add_rewrite_rule(
'tag/(\d*)$',
'index.php?pagename=community&stencil-tag=$matches[1]',
'top'
);

add_rewrite_rule(
'type/(\d*)$',
'index.php?pagename=community&stencil-type=$matches[1]',
'top'
);
}


If anyone sees the error of my ways here and can point me in the right direction I'd be incredible appreciative. Thanks.





Override "Automatically close comments on articles older than" per post?


I need to set a custom closing date for the comment field, per post. I havent started researching on how I should do this, so a indication on how to do this would be just as good as a plugin that do the work..


Thanks a lot!





Sort trash by date post was trashed


Is it possible to sort the trash for post by the last post added to trash.


EG: I trash post 4,2,1,3,5


I would like these post to be sorted in trash by the last post trashed, so they would appear in this order: 4 2 1 3 5


Currently the date filter sorts the trash by the date the post was created not the date sent to trash, i need to sort by the date sent to trash





CSRF issues with admin-ajax and profile page


Our client is using IBM App Scan Security on a WordPress installation we have provided them, and they have flagged the profile page with this issue:



Difference: Header removed from request: XMLHttpRequest
Header manipulated from:
http://myweb/admin.php?page=we_users_profile to:
http://ift.tt/1M2FMQA


We are using WordPress 3.8.3, as the client wishes to use IIS and Microsoft SQL, and the DB abstraction layer for Microsoft SQL works best for that verison and it's non-negotiable


And this is the return:



POST myweb/wp-admin/admin-ajax.php HTTP/1.1
Accept: application/json, text/javascript, */*; q=0.01
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Cookie:
wordpress_ae4ad255844b23c28a9c1c5b8f28f83d=USERNAME%7C1427361130%7Cfeefd87994da6183f2d60435c327b4
46;
wordpress_logged_in_de5ad2x5844bx3c28a9c1c5b8f28f83d=STUDENT0%7C1427361130%7C6f87d1ec5e14642401bc
1d3cba986536; wp-settings-316=mfold%3Do; wp-settings-time-316=1427188333
Referer: http://ift.tt/1M2FMQA
Accept-Language: en-SG
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/7.0; .NET4.0E;
.NET4.0C)
24/3/2015 8
Connection: Keep-Alive
Host: imsdev1
Pragma: no-cache
Content-Length: 100
interval=60&_nonce=57d64f25d4&action=heartbeat&screen_id=users_page_we_users_profile&has_focus=fa
lse
HTTP/1.1 200 OK
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
Content-Type: application/json; charset=UTF-8
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Server: Microsoft-IIS/8.5
X-Powered-By: PHP/5.5.11
X-Powered-By: ASP.NET
X-Robots-Tag: noindex
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Date: Tue, 24 Mar 2015 09:12:33 GMT
Content-Length: 26
{
"server_time": 1427188354
}


This supposedly failed their test for CSRF. Their advice is to provide a nonce, which there is already one.


Why does changing the referer still allows the request to be processed, and what can be done?





Custom post type permalink structure without post name


I have a CPT that is called city , in my permalink options panel i've set the permalink structure to /archives/%post_id% notice that there is no slug for post name.

but the permalink for the city post type is shown as archives/city/post_name.

what i need to do is to remove the post_name from the permalink structure and query it by post_id to be like archives/city/post_id





get_option returning old value for non-admin users


I am working on multisite with sub-folders. I am trying to create a plugin that will simply reduce the click counts and those counts will be visible to all users. For admin user all is working fine. But, for un-signedin user, I am getting some old value of option.


Following is the code;



add_action('wp_footer','click_counter');

function click_counter() {
?>
<div class="cc-container">
<span class="cc-counter"><?php echo get_option('click_counter_max'); ?></span>
</div>
<?php
}
?>




Contact form welcome massage problem in popup box


I'm using Contact Form 7 Plugin in easy fancybox. it's working fine.


I'm using it in http://ift.tt/1M2FOYW this site.


When visitor click on "REQURST QUERT" Button then show contact form in a light box and when click send button of the contact form then show welcome massage it's ok. But when I clicked another "REQURST QUERT" Button then the welcome massage is still.


So when click anther "REQURST QUERT" Button then I want show new contact form without welcome massage.





Redirect user to Login/Registration when adding to cart if not logged in


In my store i want user to first login then add items to cart. If login session is maintained then product will be added to cart else will be sent to login/register. I have "Add To Cart" button in few places like product list page, product detail page. Where should i change in one single place to reflect in all places. I am new to wordpress.

Please Help. Thanks.