Affichage des articles dont le libellé est Recent Questions - WordPress Development Stack Exchange. Afficher tous les articles
Affichage des articles dont le libellé est Recent Questions - WordPress Development Stack Exchange. Afficher tous les articles

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.