Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP/WordPress: override page_id in foreach loop
    primarykey
    data
    text
    <p>I have a WordPress site and currently the code it set to create titles based on the page title. The titles are: Interior House Painting, Exterior House Painting and Commercial Painting. I would like to override the titles to remove the word "house". This is the code currently:</p> <pre><code>&lt;?php // interior_painting: 18 // exterior_painting: 25 // other services: 36 $page_ids = array(18, 25, 36); $images = array('servicesInterior.jpg', 'servicesExterior.jpg', 'servicesOther.jpg'); foreach ($page_ids as $key =&gt; $page_id) { $page_post = get_post($page_id); $page_custom_key = 'home_page_info'; $page_link = $page_post-&gt;post_name; $li_class = $page_id == 36 ? 'noMargin' : ''; $title = $page_id == 18 ? 'Interior Painting' : $page_post-&gt;post_title . " "; $title = $page_id == 36 ? 'Commercial Projects' : $page_post-&gt;post_title . " "; $title = $page_id == 25 ? 'Exterior Painting' : $page_post-&gt;post_title . " "; echo '&lt;li class="' . $li_class . '"&gt; &lt;a href="' . $page_link . '"&gt;'; echo '&lt;img class="alignright size-full wp-image-349" title="servicesInterior" src="/wp-content/uploads/2011/04/' . $images[$key] . '" alt="" width="200" height="95" /&gt;&lt;/a&gt;'; echo '&lt;h2&gt;' . $title . '&lt;/h2&gt;'; echo get_post_meta($page_id, $page_custom_key, true); echo '&lt;a class="btn-find-more" href="' . $page_post-&gt;post_name . '"&gt;FIND OUT MORE&lt;/a&gt;&lt;/li&gt;'; } ?&gt; </code></pre> <p>The output is this: Interior House Painting, Exterior Painting, Commercial Painting. How do I get "house" removed from "Interior House Painting"?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload