Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • If you want to autoreplace words and make things even more dynamic, you can do it this way:

    <?php
    // Paste this code in functions.php
    // coke pepse sprite are shown like slugs here, you can also just use IDs (that would be easier)
    
    $category_extra_info = array(
            'coke' => array(
                            'link' => 'https://domain.com',
                            'image' => 'https://domain.com/logo.png'
                            ),
            'pepsi' => array(
                            'link' => 'https://domain2.com',
                            'image' => 'https://domain2.com/logo.png'
                            ),
            'sprite' => array(
                            'link' => 'https://domain3.com',
                            'image' => 'https://domain3.com/logo.png'
                            ),
    );
    
    function category_extra_info_parsing( $text ){
            // make it accessible
            global $category_extra_info;
    
            // loop and build the $replace array
            foreach ( $category_extra_info as $cat => $info ) {
                    $replace[ $cat ] = '<a href="' . $category_extra_info['coke']['link'] . '">' . $cat . '</a>';
            }
    
            // replace words now
            $text = str_replace(array_keys($replace), $replace, $text);
    
            //return modified content
            return $text;
    }
    
    add_filter('the_content', 'category_extra_info_parsing');
    
    // add_filter('the_excerpt', 'category_extra_info_parsing'); // Uncomment this line for parsing the category words
    
    // And then use it like this in your template
    // echo '<a href="' . $category_extra_info['coke']['link'] . '"><img src="' . $category_extra_info['coke']['image'] . '" alt="logo" /></a>';

    From what I see, the easiest way to do this would be to build an array like this:

    <pre>
    <?php
    // Paste this code in functions.php
    // coke pepse sprite are shown like slugs here, you can also just use IDs (that would be easier)
    
    $category_extra_info = array(
    	'coke' => array(
    			'link' => 'https://domain.com',
    			'image' => 'https://domain.com/logo.png'
    			),
    	'pepsi' => array(
    			'link' => 'https://domain2.com',
    			'image' => 'https://domain2.com/logo.png'
    			),
    	'sprite' => array(
    			'link' => 'https://domain3.com',
    			'image' => 'https://domain3.com/logo.png'
    			),
    );
    
    // And then use it like this anywhere in template
    echo '<a href="' . $category_extra_info['coke']['link'] . '" rel="nofollow"><img src="' . $category_extra_info['coke']['image'] . '" alt="logo" /></a>';
    ?>
    </pre>

    When you say a new content type, do you mean you’ll have a taxonomy or category that stores this information somewhere?

    When you say “tags”, do you mean shortcode?

    But you can use PHP if you you install this plugin: https://www.ads-software.com/extend/plugins/php-code-widget/

    Are you comfortable digging into the code or do you only want a plugin for this feature?

    Hi Patty,

    I can try to help you out. Can you either shoot me a login to the site or guide me on how I can reproduce it through some other manner?

    Thread Starter Nirav Sheth

    (@djmosoul)

    I’ve found that any .mp3 file uploaded anywhere on this domain becomes restricted. Is there something this plugin does to any core WP files or WP database that would cause all .mp3 files anywhere on the server to become restricted?

    If so, how do I undo this?

Viewing 8 replies - 1 through 8 (of 8 total)