Single post Sidebar (based on category)

I’m not good with PHP.

I use BeTheme and it’s possible to display a sidebar for each category page.

Now i need to display a sidebar for single post based on category.

For exemple :

  1. On the Category page called “WP1” I find the Sidebar “Sidebar WP1”

  2. When i vist any single post on the Category “WP1” I need to display “Sidebar WP1”

This is the sidebar-blog.php file :

http://codepad.org/TPObjKqi

I need to edit the follinwg file to get the nedded result :

http://codepad.org/sppfGQRN

Any help please ? thanks


Source: stackoverflow-php

Trigger .slideUp at anchor

I’m trying to trigger an element to slide up when I reach an anchor. The anchor ID is #blacksection and the element class is .vc_tta-panels-container. I read on another thread that you can trigger onclick actions using something like:

jQuery("#blacksection").trigger('click');

And then I’m using;

  jQuery("#blacksection").on('click', function() {
    jQuery(".vc_tta-panels-container").slideUp();

as the remaining JS. So I have this:


jQuery("#blacksection").trigger('click');
  jQuery("#blacksection").on('click', function() {
    jQuery(".vc_tta-panels-container").slideUp();
});

Which isn’t working, only just started learning JS and it’s baffling my mind, can anyone shed some light on triggering .slideUp for a class at an anchor?


Source: stackoverflow-javascript

How do prevent my site from creating multiple copies of my index page?

My WordPress site is creating dozens of copies of my index page in a folder it calls /page/, so I’ve got example.com/page/1/, example.com/page/2/, …example.com/page/49/ all the same as my index page.

I tried the following, but it only redirects the root and not all the pages within the folder.

RewriteEngine on
RewriteRule ^page/(.*)   / [R=301,L]

How do I stop this from happening or redirect the entire contents of the folder? I am not a php programmer.


Source: stackoverflow-php

How to display woocommerce sale price or regular price if there is no sale price

I’m using a woocommerce product addons plugin where I would like to display the price of a product in my dropdown section of the addons.
Currently the code I have is this

    <?php
$loop = 0;
$current_value = isset( $_POST['addon-' . sanitize_title( $addon['field-name'] ) ] ) ? wc_clean( $_POST[ 'addon-' . sanitize_title( $addon['field-name'] ) ] ) : '';
global $product;
?>
<p class="form-row form-row-wide addon-wrap-<?php echo sanitize_title( $addon['field-name'] ); ?>">
    <select class="addon addon-select" name="addon-<?php echo sanitize_title( $addon['field-name'] ); ?>">

        <?php if ( ! isset( $addon['required'] ) ) : ?>
            <option value=""><?php _e('None', 'woocommerce-product-addons'); ?></option>
        <?php else : ?>
            <!--<option value=""><?php _e('Select an option...', 'woocommerce-product-addons'); ?></option>-->
        <?php endif; ?>

        <?php foreach ( $addon['options'] as $i => $option ) :
            $loop ++;
            $price = apply_filters( 'woocommerce_product_addons_option_price',
                $option['price'] > 0 ? ' + ' . wc_price( get_product_addon_price_for_display( $option['price'] ) ) . '' : '',
                $option,
                $i,
                'select'
            );
            ?>
            <option data-raw-price="<?php echo esc_attr( $option['price'] ); ?>" data-price="<?php echo get_product_addon_price_for_display( $option['price'] ); ?>" value="<?php echo sanitize_title( $option['label'] ) . '-' . $loop; ?>" <?php selected( $current_value, sanitize_title( $option['label'] ) . '-' . $loop ); ?>><?php echo wptexturize( $option['label'] . ' (' ); echo balanceTags($product->get_price_html()) . $price ?>)</option>
        <?php endforeach; ?>

    </select>
</p>

I’m using this echo

$product->get_price_html()

what this does though is display the $”sale price” $”price” but I just want to display just the sale price or just the product price if there is no sale price. Looking at the code below, how would I accomplish this?

Thanks!


Source: stackoverflow-php

Return blank page when using gravity form api?

Following is my code:

$api_key = 'XXXXXX';
$private_key = 'XXXXXXXXXXXXXXXXXX';
$expires = strtotime( '+60 mins' );

// Insert data for Property Upload Form.
$route_1 = 'forms/8/results';
$string_to_sign_1 = sprintf( '%s:%s:%s:%s', $api_key, 'GET', $route_1, $expires );
$hash_1 = hash_hmac("sha1", $string_to_sign_1, $private_key, true);
$sig_1 = rawurlencode(base64_encode($hash_1));
$url_1 = 'https://www.abc.com.au/gravityformsapi/' . $route_1 . '?paging[page_size]=1000&api_key=' . $api_key .'&signature=' . $sig_1 . '&expires=' . $expires;
echo $url_1;

$response_1 = file_get_contents($url_1,false,NULL);

$test_1 = json_decode($response_1);
print_r($test_1);exit;

it returns a blank page, when i hit on my $url_1, it’s just redierect on some other page.
if i click on ‘https://www.abc.com.au/gravityformsapi/forms/‘, it still shows blank data.


Source: stackoverflow-php

How to wrap 2 functions into one call

Ok, so I’m working on a WordPress project (PHP) using Advanced Custom Fields and a little bit of PHP. I’ve created 2 functions that will create a container div around some text:

<section>

 <?php container_start(); ?>

   Text goes here

 <?php container_end(); ?>

</section>

This generates the following code:

<section>

 
Text goes here
</section>

This is great as it works as expected. What is going behind the scenes are these 2 functions:

function container_start() {

$container = get_sub_field('container'); 

if ($container): 
echo '
'; endif; } function container_end() { $container = get_sub_field('container'); if ($container): echo '
'; endif; }

Question is: Is there a way to optimize how is this accomplished? I find it not too practical having to call 2 functions just to add and then close a div. Is there a way I could wrap this into just one call?


Source: stackoverflow-php

Add YouTube Parameters into Shortcode for iFrame Embed

I have a shortcode specifically for adding YouTube embeds that is written like so:

// [iframe src="" scrolling="no" class="dynamicIframe" allowfullscreen="" style=""]
add_shortcode( 'iframe', 'anc_shortcode_iframe' );
function anc_shortcode_iframe( $atts, $content = null ) {

extract(shortcode_atts(array(
    'src'               => '',
    'scrolling'         => '',
    'class'             => '',
    'allowfullscreen'   => '',
    'style'             => ''
), $atts ) );

return '';

}

I’d like to add some default parameters in to all videos and can’t seem to make it work. Something like

?rel=0&list=youtubeplaylistid


Source: stackoverflow-php

I can’t add links to my wordpress theme due to this function creating empty href="#" links

I’ve been trying for the last two days to figure out how to modify the PHP files on this theme to add some links to some images. I don’t know PHP and know very little of programming in general so I am asking for help.

What I’ve been doing for the last two days:
I searched all the PHP files for the location of this section of the theme. I finally found the section and thought I had solved my problem after finding what looked like the array that the following function pulled it’s parameters from.

foreach ( $shop_isle_banners_decoded as $shop_isle_banner ) :

                    if ( ! empty( $shop_isle_banner->image_url ) ) {

                        echo '<div class="col-sm-4"><div class="content-box mt-0 mb-0"><div class="content-box-image">';

                        if ( ! empty( $shop_isle_banner->link ) ) {

                            if ( function_exists( 'icl_t' ) && ! empty( $shop_isle_banner->id ) ) {
                                $shop_isle_banner_link = icl_t( 'Banner ' . $shop_isle_banner->id, 'Banner link', $shop_isle_banner->link );

I was able to change the images by replacing the asset files but I cannot change the links. I would greatly appreciate any help anyone can provide.

Thank you in advance!


Source: stackoverflow-php

how to remove an ads script from WordPress [on hold]

Hello Smarts I have a website yesterday when i visited my website i saw an ads script that was inserted to my wordpress i viewed Website Source in Browser via Ctr+U i saw

//go.mobtrks.com/notice.php?p=1108300&interstitial=1*

i wanted to remove but coudnt find via functions.php or footer and Header in wordpress .

i also searched for the pharse via Phpmyadmin and there i also coudnt find it Please help me how to remove these pop up ads thanks you can check my website

give me any suggestion how to remove these unwanted codes thanks


Source: stackoverflow-javascript