• I have such php as this in my file:

    $STRING .= str_replace("</ul>", $EXTRA. "</ul>",$MENUCONTENT) .'</nav></div></div></div>';

    I need to turn the following into a similar code as above and im totally lost:

    Is there i way i can escape changing the code into the above ???

    <?php $totalcoupons = wp_count_posts('listing_type')->publish;?>
    We have <strong style="color: #e93030; font-size: 1.3em"><? echo $totalcoupons; ?></strong> blah blah blah <strong style="color: #e93030; font-size: 1.3em"><?php
    $count_posts = wp_count_posts('coupon_type');
    $totalcoupons = $count_posts->publish;
    $taxonomystore = wp_count_terms( 'store' );
    echo $taxonomystore; ?></strong> stores & <strong style="color: #e93030; font-size: 1.3em"><?php
    $count_posts = wp_count_posts('product');
    echo number_format("$count_posts->publish");
    ?></strong>
Viewing 10 replies - 1 through 10 (of 10 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Do you know which variable you want to target?

    Thread Starter dmaeuk

    (@dmaeuk)

    Hi Andrew.

    What i want to do is add

    <?php $totalcoupons = wp_count_posts('listing_type')->publish;?>
    We have <strong style="color: #e93030; font-size: 1.3em"><? echo $totalcoupons; ?></strong> blah blah blah <strong style="color: #e93030; font-size: 1.3em"><?php
    $count_posts = wp_count_posts('coupon_type');
    $totalcoupons = $count_posts->publish;
    $taxonomystore = wp_count_terms( 'store' );
    echo $taxonomystore; ?></strong> stores & <strong style="color: #e93030; font-size: 1.3em"><?php
    $count_posts = wp_count_posts('product');
    echo number_format("$count_posts->publish");
    ?></strong>

    Into the file that i know nothing about, lol im seriously not a coder, im a dabbler and editor.

    Normally the file consists of writable php but this one does not, i was hoping i could add this code in by escaping this somehow, im not really sure how to explain it

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    You can use “var_dump($variable)” to output the contents of a variable on the page. Do that for each until you find the one that contains the string (that you want to replace).

    Thread Starter dmaeuk

    (@dmaeuk)

    Thanks Andrew.

    I think thats gone well over my head to be honest.

    I just need to find a way to insert that code, it works on every other php page, just this page it wont work.

    Thread Starter dmaeuk

    (@dmaeuk)

    here is a better example of what i mean: I literally need to place this code between these divs

    I have this:

    $topmenustring = '<div id="core_header_navigation" class="hidden-xs">
    	<div class="'.$CORE->CSS("container", true).'">

    What i want to do is this:

    $topmenustring = '<div id="core_header_navigation" class="hidden-xs">
    
    <?php $totalcoupons = wp_count_posts('listing_type')->publish;?>
    We have <strong style="color: #e93030; font-size: 1.3em"><? echo $totalcoupons; ?></strong> blah blah blah <strong style="color: #e93030; font-size: 1.3em"><?php
    $count_posts = wp_count_posts('coupon_type');
    $totalcoupons = $count_posts->publish;
    $taxonomystore = wp_count_terms( 'store' );
    echo $taxonomystore; ?></strong> stores & <strong style="color: #e93030; font-size: 1.3em"><?php
    $count_posts = wp_count_posts('product');
    
    echo number_format("$count_posts->publish");
    ?></strong>
    
    	<div class="'.$CORE->CSS("container", true).'">

    Hi dmaeuk,
    can you try something like this

    <div id="core_header_navigation" class="hidden-xs">
    <?php $totalcoupons = wp_count_posts('listing_type')->publish; ?>
    We have <strong style="color: #e93030; font-size: 1.3em"><? echo $totalcoupons; ?></strong> blah blah blah
    <strong style="color: #e93030; font-size: 1.3em">
    	<?php
    	$count_posts = wp_count_posts('coupon_type');
    	$totalcoupons = $count_posts->publish;
    	$taxonomystore = wp_count_terms( 'store' );
    	echo $taxonomystore;
    	?>
    </strong>
    stores &
    <strong style="color: #e93030; font-size: 1.3em">
    	<?php
    	$count_posts = wp_count_posts('product');
    	echo number_format("$count_posts->publish");
    	?>
    </strong>
    <div class="<?php echo $CORE->CSS("container", true); ?>">
    Thread Starter dmaeuk

    (@dmaeuk)

    Thank you gorakh.sth

    tried this and it broke the site, thank you though.

    Thread Starter dmaeuk

    (@dmaeuk)

    it seems that i need to convert all of the php and html elements into strings, which is 100% above my capabilities.

    @dmaeuk
    Did you paste that code after closing the ?> php and before opening another php <?php ?

    Like this :

    <?php
    
    ?>
     Above code goes here.
    <?php 
    
    ?>

    Thread Starter dmaeuk

    (@dmaeuk)

    HI.

    So i can execute html but not php.

    // DISPLAY MENU
    		if(strlen($MENUCONTENT) > 1){
    		$GLOBALS['flasg_smalldevicemenubar'] = true;
    		$STRING = '<!-- [WLT] FRAMRWORK // MENU -->
    
    		<div class="container-fluid" id="core_smallmenu"><div class="row">
    
    <div style="margin: 0 0 0px 0;
        line-height: 20px;
        font-weight: 100!important;
        width: 100%;
        text-align: center;
        font-family: ubuntu;
        font-size: 14px;
        background: whitesmoke;
        color: #404040;
        padding: 5px;">
        <I CAN EXECUTE HTML HERE BUT NOT PHP>
        </div>
    
    			<div id="wlt_smalldevicemenubar">
    			<a href="javascript:void(0);" class="b1" data-toggle="collapse" data-target=".wlt_smalldevicemenu">'.$CORE->_e(array('mobile','4')).' <span class="glyphicon glyphicon-align-justify"></span></a>
    			 '.wp_nav_menu( array(
    			'container' => 'div',
    			'container_class' => 'wlt_smalldevicemenu collapse',
    			'theme_location' => 'primary',
    			'menu_class' => '',
    			'fallback_cb'     => '',
    			'echo'            => false,
    			'walker' => new Bootstrap_Walker(),
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Php question, totally lost.’ is closed to new replies.